#! /bin/sh ### BEGIN INIT INFO # Provides: mtd # Required-Start: $local_fs # Required-Stop: $local_fs # Default-Start: 24 # Default-Stop: S # Short-Description: Start/Stop the MythTV Transcoding Daemon. ### END INIT INFO PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DAEMON=/usr/bin/mtd NAME="mtd" DESC="MythTV Transcoding Daemon" test -x $DAEMON || exit 0 set -e USER=mythtv RUNDIR=/var/run/mythtv ARGS="" EXTRA_ARGS="" NICE=0 if [ -f /etc/default/mtd ]; then . /etc/default/mtd fi ARGS="$ARGS $EXTRA_ARGS" mkdir -p $RUNDIR chown -R $USER $RUNDIR unset DISPLAY unset SESSION_MANAGER case "$1" in start) if test -e $RUNDIR/$NAME.pid ; then echo "mythbackend already running, use restart instead." else echo -n "Starting $DESC: $NAME " start-stop-daemon --start --pidfile $RUNDIR/$NAME.pid \ --chuid $USER --nicelevel $NICE --background \ --make-pidfile --exec $DAEMON -- $ARGS echo "." fi ;; stop) echo -n "Stopping $DESC: $NAME " start-stop-daemon --stop --oknodo --pidfile $RUNDIR/$NAME.pid \ --chuid $USER --exec $DAEMON -- $ARGS test -e $RUNDIR/$NAME.pid && rm $RUNDIR/$NAME.pid echo "." ;; restart|force-reload) echo -n "Restarting $DESC: $NAME " start-stop-daemon --stop --oknodo --pidfile $RUNDIR/$NAME.pid \ --chuid $USER --exec $DAEMON -- $ARGS echo "." sleep 3 start-stop-daemon --start --pidfile $RUNDIR/$NAME.pid \ --chuid $USER --nicelevel $NICE --background \ --make-pidfile --exec $DAEMON -- $ARGS echo "." ;; *) N=/etc/init.d/$NAME echo "Usage: $N {start|stop|restart|force-reload}" >&2 exit 1 ;; esac exit 0