5
# Required-Start: $local_fs $remote_fs $network
6
# Required-Stop: $local_fs
7
# Default-Start: 2 3 4 5
9
# Short-Description: Start/Stop the MythExport Daemon.
12
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
13
DAEMON=/usr/bin/mythexport-daemon
17
DESC="MythExport Daemon"
19
test -x $DAEMON || exit 0
21
. /lib/lsb/init-functions
26
USER_HOME=$(grep ^$USER /etc/passwd | awk -F : '{print $6}')
27
RUNDIR=/var/run/mythtv
31
chown -R $USER $RUNDIR
38
if [ -e $RUNDIR/$NAME.pid ]; then
39
PIDDIR=/proc/$(cat $RUNDIR/$NAME.pid)
40
if [ -d ${RUNDIR} -a "$(readlink -f ${PIDDIR}/exe)" = "${COMMAND}" ]; then
41
log_success_msg "$DESC already started; use restart instead."
44
log_success_msg "Removing stale PID file $RUNDIR/$NAME"
45
rm -f $RUNDIR/$NAME.pid
48
log_daemon_msg "Starting $DESC: $NAME "
49
start-stop-daemon --start --pidfile $RUNDIR/$NAME.pid \
50
--chuid $USER --nicelevel $NICE --exec $COMMAND --startas $DAEMON $ARGS
54
log_daemon_msg "Stopping $DESC: $NAME "
55
start-stop-daemon --stop --oknodo --pidfile $RUNDIR/$NAME.pid \
56
--chuid $USER --exec $COMMAND --startas $DAEMON $ARGS
58
test -e $RUNDIR/$NAME.pid && rm $RUNDIR/$NAME.pid
61
log_daemon_msg "Restarting $DESC: $NAME "
62
start-stop-daemon --stop --oknodo --pidfile $RUNDIR/$NAME.pid \
63
--chuid $USER --exec $COMMAND --startas $DAEMON $ARGS
65
start-stop-daemon --start --pidfile $RUNDIR/$NAME.pid \
66
--chuid $USER --nicelevel $NICE --exec $COMMAND --startas $DAEMON $ARGS
70
# We want to maintain backward compatibility with Hardy,
71
# so we're not going to use status_of_proc()
72
pidofproc -p $RUNDIR/$NAME.pid $DAEMON >/dev/null && status=0 || status=$?
73
if [ $status -eq 0 ]; then
74
log_success_msg "$NAME is running"
76
log_failure_msg "$NAME is not running"
82
echo "Usage: $N {start|stop|restart|force-reload|status}" >&2