summaryrefslogtreecommitdiff
path: root/wlanWDprowl.sh
diff options
context:
space:
mode:
authorst33v <github@f3rr3t.com>2017-11-19 18:11:05 +1100
committerst33v <github@f3rr3t.com>2017-11-19 18:11:05 +1100
commit8b442454880c89c91ea85a237f60f3173324b5f2 (patch)
treeff20d25ad64034962d02a535be719065e5bb92f0 /wlanWDprowl.sh
parent206d192df6a2826e2e0863e9f568250b18ed680b (diff)
network restart might be working now
Diffstat (limited to 'wlanWDprowl.sh')
-rwxr-xr-xwlanWDprowl.sh26
1 files changed, 17 insertions, 9 deletions
diff --git a/wlanWDprowl.sh b/wlanWDprowl.sh
index 70db23c..341b932 100755
--- a/wlanWDprowl.sh
+++ b/wlanWDprowl.sh
@@ -3,22 +3,30 @@
# SJP 19 Nov 2017
#
# Designed to stop a headless wireless raspi from disappearing from the LAN.
-# IS called from a systemd timer
+# IS called from a systemd timer on an Arch linux OS.
#
cd /usr/local/bin
# The following block enables private configuration
-logdir="/path/to/my/log" # overwritten by sourcing from .logdir.config
+# I use .gitignore to exclude the config file trom github.
+logdir="/path/to/my/log" # overwritten by sourcing from a local config file.
if [ -e wlanWDlog.conf ]; then
- . wlanWDlog.conf # source directory name from local config file
+ . wlanWDlog.conf # source directory name from local config file
else echo "wlanWDlog.conf does not exist"; exit 1
fi
# end of privacy config
+# Get wireless adaptor name
+wirelessLink=$(networkctl | awk '/wlan/ {print $2}')
+
+# Prowl:
# Detect the state of the wireless network adaptor
-wirelessLink='wlan0' # ymmv
-wlanStatus=$(networkctl status ${wirelessLink} | grep 'State:')
-echo ${wlanStatus}
-echo $(whoami)
+wlanStatus=$(networkctl status ${wirelessLink} | awk '/State:/ {print $2}')
+# echo ${wlanStatus}
+
+if [ ${wlanStatus} != "routable" ]; then
+ # we have lost wireless, so log the occurrence and restart the service
+ logline="$(date) ${wlanStatus}"
+ echo ${logline} >> ${logdir}/wlanStatus.log
+ sudo systemctl restart systemd-networkd.service
+fi
-logline=$(date)${wlanStatus}
-echo ${logline} >> ${logdir}/wlanStatus.log