Page tree

Welcome to FreeSoftwareServers Confluence Wiki

Skip to end of metadata
Go to start of metadata
cat << 'EOF' >/srv/ping_check.sh
#!/bin/bash

while :; do

   sleep 5
 
        PING=""
        ping -c 1 -w 3 freesoftwareservers.com > /dev/null
        PING=$(echo $?)
        STATE=$(mysql -D zm -s -N -e "SELECT Function FROM Monitors WHERE Id=1;")
        #echo "$STATE"
        #echo "$PING" 
        if [ $PING -ne 0 ]; then
        #echo "Ping -ne 0"
                if [ $STATE != "Modect"  ];  then
                      #/srv/modect.sh
                      echo "Disable MoDect"
                fi
        elif [ $PING -eq 0 ]; then
        #echo "Ping -eq 0"
               if [ $STATE != "Monitor"  ];  then
                      #/srv/monitor.sh
                      echo "Enable Monitor"
               fi
        fi
done
EOF
chmod +x /srv/ping_check.sh

cat << 'EOF' >/etc/cron.d/ping_loop
@reboot root /srv/ping_check.sh
EOF
chmod +x /etc/cron.d/ping_loop
  • No labels