Guest User

/etc/init.d/utserver

a guest
May 2nd, 2014
348
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     #!/bin/sh -e
  2.     ### BEGIN INIT INFO
  3.     # Provides:          utserver
  4.     # Required-Start:    $local_fs $remote_fs $network
  5.     # Required-Stop:     $local_fs $remote_fs $network
  6.     # Default-Start:     2 3 4 5
  7.     # Default-Stop:      0 1 6
  8.     # Short-Description: Start or stop the utserver.
  9.     ### END INIT INFO
  10.  
  11.     CHDIR=/opt/utorrent-server-alpha-v3_3
  12.     NAME=utserver
  13.     OPTIONS="-LOGFILE"
  14.     DAEMON=$CHDIR/$NAME
  15.     USER=YOUR_USER_HERE!!!
  16.     PIDFILE=/var/run/$NAME.pid
  17.     STOP_TIMEOUT=5
  18.  
  19.     [ -x $DAEMON ] || exit 1
  20.  
  21.     . /lib/lsb/init-functions
  22.  
  23.     start_daemon () {
  24.             pgrep -U $USER $NAME >/dev/null && echo "$NAME is already running" && log_end_msg 1
  25.             rm -f $PIDFILE >/dev/null
  26.             env LANG=ru_RU.UTF-8 start-stop-daemon --start --quiet --make-pidfile --pidfile $PIDFILE --chuid $USER --chdir $CHDIR --background --exec $DAEMON -- $OPTIONS
  27.     }
  28.  
  29.     case "$1" in
  30.         start)
  31.             log_daemon_msg "Starting $NAME daemon" "$NAME"
  32.             start_daemon
  33.             log_end_msg 0
  34.             ;;
  35.         stop)
  36.             log_daemon_msg "Stopping $NAME daemon" "$NAME"
  37.             start-stop-daemon --stop --quiet --pidfile $PIDFILE --exec $DAEMON --retry $STOP_TIMEOUT || log_end_msg 1
  38.             pgrep -U $USER $NAME >/dev/null || rm -f $PIDFILE >/dev/null
  39.             log_end_msg 0
  40.             ;;
  41.         restart)
  42.             log_daemon_msg "Restarting $NAME daemon" "$NAME"
  43.             start-stop-daemon --stop --quiet --pidfile $PIDFILE --exec $DAEMON --retry $STOP_TIMEOUT || log_end_msg 1
  44.             start_daemon
  45.             log_end_msg 0
  46.             ;;
  47.         *)
  48.             echo "Usage: /etc/init.d/$NAME {start|stop|restart}"
  49.             exit 2
  50.             ;;
  51.     esac
  52.  
  53.     exit 0
RAW Paste Data