Want more features on Pastebin? Sign Up, it's FREE!
Guest

/etc/rc.d/fuppes

By: a guest on Nov 7th, 2011  |  syntax: Bash  |  size: 1.38 KB  |  views: 92  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #! /bin/bash
  2.  
  3. . /etc/rc.conf
  4. . /etc/rc.d/functions
  5.  
  6. DAEMON=fuppes
  7.  
  8. # source application-specific settings
  9. [ -f /etc/conf.d/$DAEMON ] && . /etc/conf.d/$DAEMON
  10.  
  11. # set defaults if settings are missing
  12. [ -z "$CONFIG_DIR" ] && CONFIG_DIR='/usr/var/lib/fuppes/'
  13. [ -z "$USER"       ] && USER='www'
  14.  
  15. ARGS="--config-dir '$CONFIG_DIR'"
  16.  
  17. get_pid() {
  18.   pidof -o %PPID $DAEMON
  19. }
  20.  
  21. case "$1" in
  22.   start)
  23.     stat_busy "Starting $DAEMON daemon"
  24.  
  25.     PID=$(get_pid)
  26.     if [ -z "$PID" ]; then
  27.       [ -f /var/run/$DAEMON.pid ] && rm -f /var/run/$DAEMON.pid
  28.       # RUN
  29.       su $USER -c "$DAEMON $ARGS" # &> /dev/null
  30.       #
  31.       if [ $? -gt 0 ]; then
  32.         stat_fail
  33.         exit 1
  34.       else
  35.         echo $(get_pid) > /var/run/$DAEMON.pid
  36.         add_daemon $DAEMON
  37.         stat_done
  38.       fi
  39.     else
  40.       stat_fail
  41.       exit 1
  42.     fi
  43.     ;;
  44.  
  45.   stop)
  46.     stat_busy "Stopping $DAEMON daemon"
  47.     PID=$(get_pid)
  48.     # KILL
  49.     [ ! -z "$PID" ] && kill $PID &> /dev/null
  50.     #
  51.     if [ $? -gt 0 ]; then
  52.       stat_fail
  53.       exit 1
  54.     else
  55.       rm -f /var/run/$DAEMON.pid &> /dev/null
  56.       rm_daemon $DAEMON
  57.       stat_done
  58.     fi
  59.     ;;
  60.  
  61.   restart)
  62.     $0 stop
  63.     sleep 3
  64.     $0 start
  65.     ;;
  66.  
  67.   status)
  68.     stat_busy "Checking $DAEMON status";
  69.     ck_status $DAEMON
  70.     ;;
  71.  
  72.   *)
  73.     echo "usage: $0 {start|stop|restart|status}"
  74. esac
  75.  
  76. exit 0
  77.  
  78.  
clone this paste RAW Paste Data