Debian init.d mythbackend
From MythTV Official Wiki
Author | unknown |
Description | An init.d script for launching mythbackend using the dependency-based init system in Debian 6+. |
Supports |
An init.d script for launching mythbackend using the dependency-based init system in Debian 6+. Also see, LSB_init.d_mythbackend.
Script
#!/bin/sh ### BEGIN INIT INFO # Provides: mythbackend # Required-Start: $all # Required-Stop: $local_fs $syslog # Default-Start: 3 4 5 # Default-Stop: 0 1 6 # Short-Description: starts the MythTV backend # Description: starts mythbackend using start-stop-daemon ### END INIT INFO PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin # LOCATION=/usr/local/bin DAEMON=$(which mythbackend) NAME="mythbackend" DESC="MythTV Backend" test -x $DAEMON || (echo "mythbackend is not in $PATH or it is not executable" && exit 1) set -e USER=mythtv RUNDIR=/var/run/mythtv LOGPATH=/var/log/mythtv/ ARGS="--daemon --logpath $LOGPATH --pidfile $RUNDIR/$NAME.pid" EXTRA_ARGS="-v general" NICE=0 if [ -f /etc/mythtv/mythbackend ]; then . /etc/mythtv/mythbackend fi ARGS="$ARGS $EXTRA_ARGS" mkdir -p $RUNDIR chown -R $USER $RUNDIR case "$1" in start) echo -n "Starting $DESC: $NAME" ## For those with firewire this will reset things before the backend starts. ## Should replace with keep_dct_alive.sh script at some point. # firewire_tester -R # firewire_tester -B -p 0 -n 0 -r 10 # firewire_tester -B -p 0 -n 1 -r 10 # firewire_tester -B -p 0 -n 2 -r 10 start-stop-daemon --start --pidfile $RUNDIR/$NAME.pid \ --chuid $USER --nicelevel $NICE --exec $DAEMON -- $ARGS echo "." ;; stop) echo -n "Stopping $DESC: $NAME " start-stop-daemon --stop --oknodo --pidfile $RUNDIR/$NAME.pid \ --chuid $USER --exec $DAEMON -- $ARGS 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 --exec $DAEMON -- $ARGS echo "." ;; *) N=/etc/init.d/$NAME # echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2 echo "Usage: $N {start|stop|restart|force-reload}" >&2 exit 1 ;; esac exit 0
A similar script to this was used in the mythtv deb package. It causes errors like: "errror creating /.qt" This error in itself seems benign. The cause of this error is the HOME environment setting not being set correctly. This caused more problems for tv listings updates that mythtv calls, or any other program that mythtv calls and assumes it can write files to the home directory.
A simple fix, put
HOME=/home/mythtv
after the USER=mythtv line.
Installation
1) Copy paste to /etc/init.d/mythbackend
2) Apply correct permissions:
chmod 755 /etc/init.d/mythbackend
3) Tell Debian to use this init script
- For Debian 6+ (verbose mode tells you what's going on)
insserv -v mythbackend
- For Debian 5 or lower (will not use LSB metadata, may need to remove "defaults" and fiddle the "SS KK" numbers to get it to execute after mysql, in any case you should not be installing MythTV on Debian 5 as it's support will end after Feb 2012)
update-rc.d mythbackend defaults