Guest User

Untitled

a guest
Jan 18th, 2011
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.23 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # Copyright (C) 2005-2011 by Jordi Sanfeliu <[email protected]>
  4. #
  5. # monitorix    Starts/Stop the Monitorix daemon
  6. #
  7. # chkconfig: 2345 99 10
  8. # description: lightweight system monitoring tool
  9. # processname: monitorix
  10. # pidfile: /var/run/monitorix.pid
  11.  
  12. # Source function library.
  13. . /etc/init.d/functions
  14.  
  15. RETVAL=0
  16. LOCK="/var/lock/subsys/monitorix"
  17. PROG="monitorix"
  18. CONF="/etc/monitorix.conf"
  19.  
  20. start() {
  21.     if [ ! -f $LOCK ] ; then
  22.         echo -n $"Starting $PROG: "
  23.         daemon /usr/bin/$PROG -c $CONF && success || failure
  24.         RETVAL=$?
  25.         if [ $RETVAL -eq 0 ] ; then
  26.             pid=`pidof -o %PPID $PROG`
  27.             touch /var/lock/subsys/$PROG
  28.             echo $pid > /var/run/$PROG.pid
  29.             echo
  30.         fi
  31.     fi
  32. }
  33.  
  34. stop() {
  35.     echo -n $"Stopping $PROG: "
  36.     killproc $PROG
  37.     RETVAL=$?
  38.     rm -f /var/lock/subsys/$PROG
  39.     rm -f /var/run/$PROG
  40.     echo
  41. }
  42.  
  43. restart() {
  44.     stop
  45.     start
  46. }
  47.  
  48. case "$1" in
  49.     start)
  50.         start
  51.         ;;
  52.     stop)
  53.         stop
  54.         ;;
  55.     restart)
  56.         restart
  57.         ;;
  58.     status)
  59.             status $PROG
  60.         ;;
  61.     *)
  62.         echo $"Usage: $0 {start|stop|restart|status}"
  63.         exit 1
  64. esac
  65.  
  66. exit $RETVAL
Advertisement
Add Comment
Please, Sign In to add comment