Project

General

Profile

debian build from git ok, question: how to autostart?

Added by james walsh over 11 years ago

I guess I need to add an init.d script

could a kind soul share where when and how to get tvheadend to autostart

I am running tvheadend 3.2 on a debian 6 server

thanks in advance!


Replies (1)

RE: debian build from git ok, question: how to autostart? - Added by Franklyn van der Toorn over 11 years ago

The easy way is to add tvheadend too your /etc/rc.local. The line would look something like: tvheaded -f -u (user to run it as) -g (group).

The other solution would be to create a script like this one in /etc/init.d:


### BEGIN INIT INFO
# Provides:          tvheadend
# Required-Start:    $remote_fs $syslog userhdhomerun
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start tvheadend daemon at boot time
# Description:       Enable service provided by tvheadend daemon.
### END INIT INFO

TVHNAME="tvheadend" 
TVHBIN="/usr/bin/tvheadend" 
TVHUSER="hts" 
TVHGROUP="hts" 

case "$1" in
  start)
    echo "Starting tvheadend" 
    sleep 5
    start-stop-daemon --start --user ${TVHUSER} --exec ${TVHBIN} -- \
                -u ${TVHUSER} -g ${TVHGROUP} -f -C
  ;;
  stop)
    echo "Stopping tvheadend" 
    start-stop-daemon --stop --quiet --name ${TVHNAME} --signal 2
  ;;
  restart)
    echo "Restarting tvheadend" 

    start-stop-daemon --stop --quiet --name ${TVHNAME} --signal 2

    start-stop-daemon --start --user ${TVHUSER} --exec ${TVHBIN} -- \
                -u ${TVHUSER} -g ${TVHGROUP} -f -C

  ;;
  *)
    echo "Usage: tvheadend {start|stop|restart}" 
    exit 1
esac
exit 0

Give it the right permissions with chmod 755 and then with the command "insserv nameofyourscript" make it run everytime you boot your server.

    (1-1/1)