diff --git a/stage7-addons/01-wifi-bootstrap/files/hotspot/hotspot.sh b/stage7-addons/01-wifi-bootstrap/files/hotspot/hotspot.sh index 8eb34e3157a5577eaae9fd747b2fbae5fb603e39..a36d5ffcfaba1e47488a697e7297f16575080c57 100755 --- a/stage7-addons/01-wifi-bootstrap/files/hotspot/hotspot.sh +++ b/stage7-addons/01-wifi-bootstrap/files/hotspot/hotspot.sh @@ -5,6 +5,7 @@ function usage() { echo "* start: start the hotspot" echo "* restart: stop and restart the hotspot" echo "* stop: stops the hotspot" + echo "* status: shows the hotspot status" echo "* reapply: reapplies non-hotspot dhcpcd.conf -- requires hotspot to be off" exit 1 } @@ -14,23 +15,14 @@ case $cmd in start) action="start";; restart) action="restart";; stop) action="stop";; + status) action="status";; autostart) action="autostart";; reapply) action="reapply";; *) usage;; esac function isRunning() { - systemctl is-active --quiet hostapd - hostapdStatus=$? - systemctl is-active --quiet dnsmasq - dnsmasqStatus=$? - - if [ $hostapdStatus -eq 0 ] && [ $dnsmasqStatus -eq 0 ] - then - return 0 - else - return 1 - fi + systemctl is-active --quiet hostapd && systemctl is-active --quiet dnsmasq } function ethernetConnected() { @@ -50,6 +42,13 @@ function flushIPsAndRestartDhcpcd() { systemctl restart networking.service } +function printHotspotStatus() { + if isRunning + then echo "Hotspot is running" + else echo "Hotspot is NOT running" + fi +} + function stopHotspot() { if ! isRunning then @@ -138,6 +137,7 @@ function reapplyDHCPCD() { } function action() { + [ "$action" == "status" ] && printHotspotStatus; [ "$action" == "stop" ] && stopHotspot; [ "$action" == "restart" ] && stopHotspot && startHotspot; [ "$action" == "start" ] && startHotspot;