Advertisement
Guest User

Untitled

a guest
Jan 4th, 2013
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.02 KB | None | 0 0
  1. #! /bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides:          mythtv-backend
  4. # Required-Start:    $local_fs $remote_fs
  5. # Required-Stop:     $local_fs $remote_fs
  6. # Should-Start:      mysql
  7. # Should-Stop:       mysql
  8. # Default-Start:     2 3 4 5
  9. # Default-Stop:      0 1 6
  10. # Short-Description: Start/Stop the MythTV server.
  11. ### END INIT INFO
  12.  
  13. if [ -f /etc/default/locale ]; then
  14.   . /etc/default/locale
  15.   export LANG
  16. fi
  17.  
  18. PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  19. DAEMON=/usr/bin/mythbackend
  20. NAME="mythbackend"
  21. DESC="MythTV server"
  22.  
  23. test -x $DAEMON || exit 0
  24.  
  25. set -e
  26.  
  27. USER=mythtv
  28. RUNDIR=/var/run/mythtv
  29. ARGS="--daemon --syslog local6 --pidfile $RUNDIR/$NAME.pid"
  30. EXTRA_ARGS=""
  31. NICE=0
  32.  
  33. if [ -f /etc/default/mythtv-backend ]; then
  34.   . /etc/default/mythtv-backend
  35. fi
  36.  
  37. ARGS="$ARGS $EXTRA_ARGS"
  38.  
  39. mkdir -p $RUNDIR
  40. chown -R $USER $RUNDIR
  41.  
  42. unset DISPLAY
  43. unset SESSION_MANAGER
  44.  
  45. case "$1" in
  46.   start)
  47.     if test -e $RUNDIR/$NAME.pid ; then
  48.         echo "mythbackend already running, use restart instead."
  49.     else
  50.         echo -n "Starting $DESC: $NAME "
  51.         start-stop-daemon --start --pidfile $RUNDIR/$NAME.pid \
  52.             --chuid $USER --nicelevel $NICE --exec $DAEMON -- $ARGS
  53.         echo "."
  54.     fi
  55.     ;;
  56.   stop)
  57.     echo -n "Stopping $DESC: $NAME "
  58.     start-stop-daemon --stop --oknodo --pidfile $RUNDIR/$NAME.pid \
  59.         --chuid $USER --exec $DAEMON -- $ARGS
  60.     test -e $RUNDIR/$NAME.pid && rm $RUNDIR/$NAME.pid
  61.     echo "."
  62.     ;;
  63.   restart|force-reload)
  64.     echo -n "Restarting $DESC: $NAME "
  65.     start-stop-daemon --stop --oknodo --retry 10 --pidfile $RUNDIR/$NAME.pid \
  66.                 --chuid $USER --exec $DAEMON -- $ARGS
  67.     echo "."
  68.     start-stop-daemon --start --pidfile $RUNDIR/$NAME.pid \
  69.                 --chuid $USER --nicelevel $NICE --exec $DAEMON -- $ARGS
  70.     echo "."
  71.     ;;
  72.   reload)
  73.     start-stop-daemon --stop --oknodo --signal HUP --pidfile \
  74.     $RUNDIR/$NAME.pid --chuid $USER --exec $DAEMON -- $ARGS
  75.     echo "."
  76.     ;;
  77.   *)
  78.     N=/etc/init.d/$NAME
  79.     echo "Usage: $N {start|stop|restart|force-reload}" >&2
  80.     exit 1
  81.     ;;
  82. esac
  83.  
  84. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement