2012-12-28 13:37:43 +01:00
|
|
|
#! /bin/sh
|
|
|
|
# tvheadend startup script inspired by the Debian one in the package
|
|
|
|
|
|
|
|
# Author: Yann E. MORIN <yann.morin.1998@free.fr>
|
|
|
|
|
|
|
|
PATH=/usr/sbin:/usr/bin:/sbin:/bin
|
|
|
|
NAME=tvheadend
|
|
|
|
PIDFILE=/var/run/$NAME.pid
|
|
|
|
|
|
|
|
# Read configuration variable file if it is present
|
|
|
|
[ -r "/etc/default/${NAME}" ] && . "/etc/default/${NAME}"
|
|
|
|
|
|
|
|
ARGS="-f"
|
|
|
|
[ -z "${TVH_USER}" ] || ARGS="${ARGS} -u ${TVH_USER}"
|
|
|
|
[ -z "${TVH_GROUP}" ] || ARGS="${ARGS} -g ${TVH_GROUP}"
|
|
|
|
[ -z "${TVH_ADAPTERS}" ] || ARGS="${ARGS} -a ${TVH_ADAPTERS}"
|
|
|
|
[ -z "${TVH_HTTP_PORT}" ] || ARGS="${ARGS} -w ${TVH_HTTP_PORT}"
|
|
|
|
[ -z "${TVH_HTSP_PORT}" ] || ARGS="${ARGS} -e ${TVH_HTSP_PORT}"
|
|
|
|
[ "${TVH_DEBUG}" = "1" ] && ARGS="${ARGS} -s"
|
|
|
|
|
2016-03-28 17:15:47 +02:00
|
|
|
# If first run, start in wizard mode
|
|
|
|
if [ -z "$(ls -1 /home/tvheadend/.hts/tvheadend/accesscontrol/ 2>/dev/null)" ]; then
|
|
|
|
ARGS="${ARGS} -C"
|
|
|
|
fi
|
|
|
|
|
2012-12-28 13:37:43 +01:00
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
printf "Starting TVHeadend daemon: "
|
2018-04-16 04:29:43 +02:00
|
|
|
if start-stop-daemon -S -q -p ${PIDFILE} -m --exec /usr/bin/tvheadend -- ${ARGS}; then
|
2012-12-28 13:37:43 +01:00
|
|
|
printf "OK\n"
|
|
|
|
else
|
|
|
|
printf "failed\n"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
stop)
|
2014-08-20 03:20:47 +02:00
|
|
|
printf "Stopping TVHeadend daemon: "
|
2012-12-28 13:37:43 +01:00
|
|
|
start-stop-daemon -K -q -p ${PIDFILE} -s TERM
|
|
|
|
sleep 2
|
|
|
|
if start-stop-daemon -K -q -p ${PIDFILE} -t; then
|
|
|
|
printf "failed, killing: "
|
|
|
|
start-stop-daemon -K -q -p ${PIDFILE} -s KILL -o
|
|
|
|
fi
|
|
|
|
printf "OK\n"
|
|
|
|
;;
|
|
|
|
restart|force-reload)
|
|
|
|
"${0}" stop
|
|
|
|
sleep 2
|
2013-03-08 12:53:29 +01:00
|
|
|
"${0}" start
|
2012-12-28 13:37:43 +01:00
|
|
|
;;
|
|
|
|
*)
|
2014-08-20 03:20:47 +02:00
|
|
|
echo "Usage: $0 {start|stop|restart|force-reload}" >&2
|
2012-12-28 13:37:43 +01:00
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
:
|