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

farmerjoe on Arch

By: a guest on Sep 15th, 2010  |  syntax: Bash  |  size: 0.81 KB  |  views: 28  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print  |  QR code  |  clone
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. PID=`pidof -o %PPID /opt/farmerjoe/farmerjoe`
  7. case "$1" in
  8.   start)
  9.     stat_busy "Starting Farmerjoe"
  10.     [ -z "$PID" ] && /opt/farmerjoe/farmerjoe > /var/log/farmerjoe 2>&1 &
  11.     if [ $? -gt 0 ]; then
  12.       stat_fail
  13.     else
  14.       echo $(pidof -o %PPID -x /opt/farmerjoe/farmerjoe) > /var/run/farmerjoe.pid
  15.       add_daemon farmerjoe
  16.       stat_done
  17.     fi
  18.     ;;
  19.   stop)
  20.     stat_busy "Stopping Farmerjoe"
  21.     #[ ! -z "$PID" ]  && kill $PID &> /dev/null
  22.     pkill -f "farmerjoe"
  23.     if [ $? -gt 0 ]; then
  24.       stat_fail
  25.     else
  26.       rm /var/run/farmerjoe.pid
  27.       rm_daemon farmerjoe
  28.       stat_done
  29.     fi
  30.     ;;
  31.   restart)
  32.     $0 stop
  33.     sleep 1
  34.     $0 start
  35.     ;;
  36.   *)
  37.     echo "usage: $0 {start|stop|restart}"  
  38. esac
  39. exit 0
clone this paste RAW Paste Data