Advertisement
Guest User

Untitled

a guest
May 2nd, 2012
339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.70 KB | None | 0 0
  1. #!/bin/sh
  2. #
  3. # chkconfig: - 99 01
  4. # description: bmc-watchdog startup script
  5. #
  6. ### BEGIN INIT INFO
  7. # Provides: bmc-watchdog
  8. # Required-Start: $network $remote_fs $syslog
  9. # Required-Stop:  $network $remote_fs $syslog
  10. # Default-Stop:   0 1 2 6
  11. # Short-Description: Start and stop bmc-watchdog
  12. # Description: BMC watchdog timer daemon
  13. ### END INIT INFO
  14.  
  15. DAEMON=/usr/sbin/bmc-watchdog
  16. PIDFILE=/var/run/bmc-watchdog.pid
  17. LOCKFILE=/var/lock/subsys/bmc-watchdog
  18. CONFFILE=/etc/sysconfig/bmc-watchdog
  19.  
  20. [ -f $DAEMON ] || exit 5
  21.  
  22. if [ -r $CONFFILE ]; then
  23.         . $CONFFILE
  24. fi
  25.  
  26. # Load Redhat or Suse appropriate libs
  27. if [ -f /etc/rc.d/init.d/functions ] ; then
  28.     . /etc/rc.d/init.d/functions
  29.     Xstart() {
  30.  
  31.         # Default deamon mode
  32.         #
  33.         # timer use = SMS/OS
  34.         # pre-timeout interrupt = none
  35.         # action = reset
  36.         # -F, -P, -L, -S, -O - clear flags
  37.         # initial-countdown = 900 seconds (15 mins)
  38.         # reset-period = 60 seconds
  39.  
  40.         daemon -20 $DAEMON $OPTIONS
  41.         RETVAL=$?
  42.         echo
  43.         [ $RETVAL -eq 0 ] && touch $LOCKFILE
  44.  
  45.         /sbin/pidof $DAEMON > $PIDFILE 2>/dev/null
  46.     }
  47.     Xstop() {
  48.         killproc bmc-watchdog
  49.         RETVAL=$?
  50.         echo
  51.         [ $RETVAL -eq 0 ] && rm -f $LOCKFILE
  52.     }
  53.     Xstatus() {
  54.         status bmc-watchdog
  55.         RETVAL=$?
  56.         return $RETVAL
  57.     }
  58.     Xcondrestart() {
  59.         if test -e $LOCKFILE; then
  60.             $0 stop
  61.             $0 start
  62.             RETVAL=$?
  63.         fi
  64.     }
  65.     Xexit() {
  66.         exit $RETVAL
  67.     }
  68. elif [ -f /etc/rc.status ] ; then
  69.     . /etc/rc.status
  70.     Xstart() {
  71.         startproc -20 $DAEMON $OPTIONS
  72.         rc_status -v
  73.     }
  74.     Xstop() {
  75.         killproc -TERM $DAEMON
  76.         rc_status -v
  77.     }
  78.     Xstatus() {
  79.         echo -n "Checking for bmc-watchdog: "
  80.         checkproc $DAEMON
  81.         rc_status -v
  82.     }
  83.     Xcondrestart() {
  84.         $0 status
  85.         if test $? = 0; then
  86.             $0 restart
  87.         else
  88.             rc_reset
  89.         fi
  90.         rc_status
  91.     }
  92.     Xexit() {
  93.         rc_exit
  94.     }
  95. else
  96.     echo "Unknown distribution type"
  97.     exit 1
  98. fi
  99.  
  100. RETVAL=0
  101.  
  102. case "$1" in
  103.    start)
  104.         echo -n "Starting bmc-watchdog: "
  105.         Xstatus >/dev/null 2>&1 && exit 0
  106.         Xstart
  107.         ;;
  108.  
  109.   stop)
  110.         echo -n "Shutting down bmc-watchdog: "
  111.         Xstop
  112.         ;;
  113.  
  114.   restart)
  115.         $0 stop
  116.         $0 start
  117.         RETVAL=$?
  118.         ;;
  119.   status)
  120.         Xstatus
  121.         ;;
  122.   condrestart|try-restart|force-reload)
  123.         Xcondrestart
  124.         ;;
  125.   *)
  126.         echo "Usage: $0 {start|stop|restart|status|condrestart|try-restart|force-reload}"
  127.         exit 2
  128. esac
  129.  
  130. exit $RETVAL
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement