open-plc-utils: new package
[buildroot-gz.git] / package / tvheadend / S99tvheadend
blob75b66f37f27c0a8050452bdf55f26bc01348f01b
1 #! /bin/sh
2 # tvheadend startup script inspired by the Debian one in the package
4 # Author: Yann E. MORIN <yann.morin.1998@free.fr>
6 PATH=/usr/sbin:/usr/bin:/sbin:/bin
7 NAME=tvheadend
8 DAEMON=/usr/bin/$NAME
9 PIDFILE=/var/run/$NAME.pid
11 [ -f "${DAEMON}" -a -x "${DAEMON}" ] || exit 0
13 # Read configuration variable file if it is present
14 [ -r "/etc/default/${NAME}" ] && . "/etc/default/${NAME}"
16 ARGS="-f"
17 [ -z "${TVH_USER}" ] || ARGS="${ARGS} -u ${TVH_USER}"
18 [ -z "${TVH_GROUP}" ] || ARGS="${ARGS} -g ${TVH_GROUP}"
19 [ -z "${TVH_ADAPTERS}" ] || ARGS="${ARGS} -a ${TVH_ADAPTERS}"
20 [ -z "${TVH_HTTP_PORT}" ] || ARGS="${ARGS} -w ${TVH_HTTP_PORT}"
21 [ -z "${TVH_HTSP_PORT}" ] || ARGS="${ARGS} -e ${TVH_HTSP_PORT}"
22 [ "${TVH_DEBUG}" = "1" ] && ARGS="${ARGS} -s"
24 case "$1" in
25 start)
26 printf "Starting TVHeadend daemon: "
27 if start-stop-daemon -S -q -p ${PIDFILE} -m --exec "${DAEMON}" -- ${ARGS}; then
28 printf "OK\n"
29 else
30 printf "failed\n"
33 stop)
34 printf "Stopping TVHeadend daemon: "
35 start-stop-daemon -K -q -p ${PIDFILE} -s TERM
36 sleep 2
37 if start-stop-daemon -K -q -p ${PIDFILE} -t; then
38 printf "failed, killing: "
39 start-stop-daemon -K -q -p ${PIDFILE} -s KILL -o
41 printf "OK\n"
43 restart|force-reload)
44 "${0}" stop
45 sleep 2
46 "${0}" start
49 echo "Usage: $0 {start|stop|restart|force-reload}" >&2
50 exit 1
52 esac