Guest User

Untitled

a guest
Jan 19th, 2011
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.79 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. . /etc/rc.conf
  4. . /etc/rc.d/functions
  5.  
  6. PID=`pidof -o %PPID /usr/bin/monitorix`
  7. MARGS="-c /etc/monitorix.conf"
  8.  
  9. case "$1" in
  10.   start)
  11.    stat_busy "Starting Monitorix"
  12.     if [ -z "$PID" ]; then
  13.        /usr/bin/monitorix $MARGS &
  14.     fi
  15.     if [ ! -z "$PID" -o $? -gt 0 ]; then
  16.       stat_fail
  17.     else
  18.       PID=`pidof -o %PPID /usr/bin/monitorix`
  19.       echo $PID > /var/run/monitorix.pid
  20.       add_daemon monitorix
  21.       stat_done
  22.     fi
  23.     ;;
  24.  
  25.   stop)
  26.     stat_busy "Stopping Monitorix"
  27.     [ ! -z "$PID" ]  && kill $PID &> /dev/null
  28.     if [ $? -gt 0 ]; then
  29.       stat_fail
  30.     else
  31.       rm_daemon monitorix
  32.       stat_done
  33.     fi
  34.     ;;
  35.  
  36.   restart)
  37.     $0 stop
  38.     sleep 1
  39.     $0 start
  40.     ;;
  41.   *)
  42.     echo "usage: $0 {start|stop|restart}"
  43. esac
Advertisement
Add Comment
Please, Sign In to add comment