From 8b442454880c89c91ea85a237f60f3173324b5f2 Mon Sep 17 00:00:00 2001 From: st33v Date: Sun, 19 Nov 2017 18:11:05 +1100 Subject: network restart might be working now --- wlanWDprowl.sh | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'wlanWDprowl.sh') 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 -- cgit v1.3