I'm trying to understand this script thus have tried to comment each line. Could someone check my comments are accurate, and help me with my gaps in understanding
#!/bin/bash
TESTIP=192.168.1.1 :: router ip address
ping -c4 ${TESTIP} > /dev/null
:: -c4 = Stop after sending (and receiving) 4 count ECHO_RESPONSE packets
:: ${} = not sure what the curly brackets are?
:: /dev/null = throw away any error messages
if [ $? != 0 ] ::$?= return value is not equal to zero, i.e. good wifi
then
logger -t $0 "WiFi seems down, restarting"
::logger = log to file, can not find any messages in the syslog or messages files
:: -t = tag
:: $0 = DO NOT UNDERSTAND!! how can there be a variable called "0"?
ifdown --force wlan0 :: disables the wifi interface
ifup wlan0 ::enable it again
else
logger -t $0 "WiFi seems up."
fi
Iv'e tested this script on my pi, by running it every min, but cannot see any messages in the logs from the script. I can however see it being called by the cron.
./script-file.sh tag-name
.