Setup:
sudo su echo "up" > /root/nasstatus.txt
Mount point check is a simple empty file sitting at: /mnt/nas/file.txt If this file goes missing, we call speak.sh to say that the NAS is down.
nano /root/checkSamba.sh
#!/bin/bash FILE=/mnt/nas/file.txt STATUSFILE=/root/nasstatus.txt # keep track of last status NASDOWN=$(cat "$STATUSFILE") if [ ! -f $FILE ]; then nohup /opt/settings/scripts/speak.sh "NAS is down" >/dev/null 2>&1 & echo "down" > $STATUSFILE else if [ "$NASDOWN" = "down" ]; then nohup /opt/settings/scripts/speak.sh "NAS is now back up and running" >/dev/null 2>&1 & echo "up" > $STATUSFILE fi fi # echo "nasdown is: $NASDOWN"