Advertisement
Trinket

couchpotato

Mar 3rd, 2013
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.87 KB | None | 0 0
  1. #! /bin/sh
  2.  
  3. ### BEGIN INIT INFO
  4. # Provides:          couchpotato
  5. # Required-Start:    $local_fs $network $remote_fs
  6. # Required-Stop:     $local_fs $network $remote_fs
  7. # Should-Start:      $NetworkManager
  8. # Should-Stop:       $NetworkManager
  9. # Default-Start:     2 3 4 5
  10. # Default-Stop:      0 1 6
  11. # Short-Description: starts instance of CouchPotato
  12. # Description:       starts instance of CouchPotato using start-stop-daemon
  13. ### END INIT INFO
  14.  
  15. ############### EDIT ME ##################
  16. # path to app
  17. APP_PATH=/usr/local/download/couchpotato
  18.  
  19. # user
  20. RUN_AS=couchpotato
  21. GROUP=download
  22. # path to python bin
  23. DAEMON=/usr/bin/python
  24.  
  25. # Path to store PID file
  26. PID_FILE=/var/run/couchpotato/server.pid
  27. PID_PATH=$(dirname $PID_FILE)
  28.  
  29. # script name
  30. NAME=couchpotato
  31.  
  32. # app name
  33. DESC=CouchPotato
  34.  
  35. # startup args
  36. DAEMON_OPTS=" CouchPotato.py --daemon --pid_file=${PID_FILE} --data_dir=/var/couchpotato --config_file=/var/couchpotato/couchpotato.ini --debug"
  37.  
  38. ############### END EDIT ME ##################
  39.  
  40. test -x $DAEMON || exit 0
  41.  
  42. set -e
  43.  
  44. case "$1" in
  45.   start)
  46.         echo "Starting $DESC"
  47.         rm -rf $PID_PATH || return 1
  48.         install -d --mode=0755 -o $RUN_AS $PID_PATH || return 1
  49.         start-stop-daemon -N 10 -d $APP_PATH -c $RUN_AS:$GROUP --start --background --pidfile $PID_FILE --exec $DAEMON -- $DAEMON_OPTS
  50.         ;;
  51.   stop)
  52.         echo "Stopping $DESC"
  53.         start-stop-daemon --stop --pidfile $PID_FILE --retry 15
  54.         ;;
  55.  
  56.   restart|force-reload)
  57.         echo "Restarting $DESC"
  58.         start-stop-daemon --stop --pidfile $PID_FILE --retry 15
  59.         start-stop-daemon -N 10 -d $APP_PATH -c $RUN_AS:$GROUP --start --background --pidfile $PID_FILE --exec $DAEMON -- $DAEMON_OPTS
  60.         ;;
  61.   *)
  62.         N=/etc/init.d/$NAME
  63.         echo "Usage: $N {start|stop|restart|force-reload}" >&2
  64.         exit 1
  65.         ;;
  66. esac
  67.  
  68. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement