SHARE
TWEET

basskozz

a guest Feb 4th, 2009 172 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh
  2. ###
  3. # 2/4/09
  4. # adv-shutdown.sh
  5. # Advanced Shutdown Script
  6. # Ref - http://basskozz.wordpress.com/2009/02/04/advanced-shutdown-script-part-2-check-for-services/
  7. ###
  8.  
  9. SERVICE_LIST=’mysecurebackup’
  10. IP_LIST=’192.168.1.101 192.168.1.102 192.168.1.103 192.168.1.104‘
  11.  
  12. for SERVICE  in $SERVICE_LIST; do
  13.    if ps ax | grep -v grep | grep $SERVICE > /dev/null
  14.    then
  15.       echo “$SERVICE service is running: $(date)” >> /home/user/scripts/adv-shutdown.log
  16.       exit
  17.    else
  18.       echo “$SERVICE is NOT running: $(date)” >> /home/user/scripts/adv-shutdown.log
  19.    fi
  20. done
  21.  
  22. ALIVE=0
  23. for IP  in $IP_LIST; do
  24.    ping -q -c1 -w5 $IP
  25.    if [ $? -eq 0 ]; then
  26.       ALIVE=1
  27.       echo “$IP is alive: $(date)” >> /home/user/scripts/adv-shutdown.log
  28.       break
  29.    fi
  30. done
  31.  
  32. if [ $ALIVE -eq 0 ]; then
  33.    echo “***ShutDown***  $(date)” >> /home/user/scripts/adv-shutdown.log
  34.    echo “###########################” >> /home/user/scripts/adv-shutdown.log
  35.    /sbin/shutdown -h now
  36. fi
RAW Paste Data
Top