Project

General

Profile

[SOLVED] TVHeadend not auto-starting

Added by Kevin J about 9 years ago

Hi, I am using Xubuntu 15.04 64 bit, TVHeadend all setup and working correctly, except when I reboot the system, TVHeadend does not auto start, I have to use:

sudo service tvheadend restart

How do I get it to auto-start on reboot?

I do have Xubuntu set to autologin.

In my /etc/init.d/tvheadend file I have the below:

#/bin/sh
### BEGIN INIT INFO
# Provides:          tvheadend
# Required-Start:    $local_fs $remote_fs udev
# Required-Stop:     $local_fs $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
### END INIT INFO

# Author: Andreas Öman

# Do NOT "set -e" 

# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/usr/sbin:/usr/bin:/sbin:/bin
DESC="Tvheadend" 
NAME=tvheadend
DAEMON=/usr/bin/$NAME
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME

# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0

# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME

# Configure command line options
[ "$TVH_ENABLED" = "1" ] || exit 0

ARGS="-f" 
[ -z "$TVH_USER"      ] || ARGS="$ARGS -u $TVH_USER" 
[ -z "$TVH_GROUP"     ] || ARGS="$ARGS -g $TVH_GROUP" 
[ -z "$TVH_CONF_DIR"  ] || ARGS="$ARGS -c $TVH_CONF_DIR" 
[ -z "$TVH_ADAPTERS"  ] || ARGS="$ARGS -a $TVH_ADAPTERS" 
[ "$TVH_IPV6" = "1"   ] && ARGS="$ARGS -6" 
[ -z "$TVH_HTTP_PORT" ] || ARGS="$ARGS --http_port $TVH_HTTP_PORT" 
[ -z "$TVH_HTTP_ROOT" ] || ARGS="$ARGS --http_root $TVH_HTTP_ROOT" 
[ -z "$TVH_HTSP_PORT" ] || ARGS="$ARGS --htsp_port $TVH_HTSP_PORT" 
[ -z "$TVH_ARGS"      ] || ARGS="$ARGS $TVH_ARGS" 
[ "$TVH_DEBUG" = "1"  ] && ARGS="$ARGS -s" 

# Load the VERBOSE setting and other rcS variables
[ -f /etc/default/rcS ] && . /etc/default/rcS

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions

#
# Function that starts the daemon/service
#
do_start()
{
        # Return
        #   0 if daemon has been stopped
        #   1 if daemon was already stopped
        #   2 if daemon could not be stopped
        #   other if a failure occurred
        start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
        RETVAL="$?" 
        [ "$RETVAL" = 2 ] && return 2
        # Many daemons don't delete their pidfiles when they exit.
        rm -f $PIDFILE
        return "$RETVAL" 
}

case "$1" in
  start)
        [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" 
        do_start
        case "$?" in
                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
        esac
        ;;
  stop)
        [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" 
        do_stop
        case "$?" in
                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
        esac
        ;;
  restart|force-reload)
        #
        # If the "reload" option is implemented then remove the
        # 'force-reload' alias
        #
        log_daemon_msg "Restarting $DESC" "$NAME" 
        do_stop
        case "$?" in
          0|1)
                do_start
                case "$?" in
                        0) log_end_msg 0 ;;
                        1) log_end_msg 1 ;; # Old process is still running
                        *) log_end_msg 1 ;; # Failed to start
                esac
                ;;
          *)
                # Failed to stop
                log_end_msg 1
                ;;
        esac
        ;;
  *)
        echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
        exit 3
        ;;
esac

:


Replies (9)

RE: TVHeadend not auto-starting - Added by K Shea about 9 years ago

I'm just curious, did you by any chance use Webmin or some similar tool to temporarily disable starting after a reboot, and then after you tried to re-enable starting at boot you found that it wouldn't? That is what happened to me using Debian Wheezy and TVHeadEnd 3.9. The only thing that fixed it was when a new version of TVHeadEnd was offered and I upgraded.

So I would suggest you check to see if there is a newer version of TVHeadEnd available for your distribution and if so, install it, and then never use any external programs to disable startup at boot. If you think you have to stop TVHeadEnd because you got a kernel update and now need to rebuild some tuner drivers, you don't. Just install the kernel update, reboot, rebuild your tuner drivers, and reboot again. Sure, TVheadEnd will not be able to access the tuners for a few minutes but that doesn't hurt anything (unless you have something scheduled to record during that period, in which case the recording will probably fail), but it should find them just fine after you have rebuilt the drivers and rebooted (note this is not required for all makes/models of tuners, so if you haven't had to do this in the past then it probably doesn't apply to you).

If there is no newer version of TVHeadEnd available, you may need to use whatever option is used in your package manager to force a reinstall of the current version. I won't say with 100% certainty that will work, but I do know that upgrading to a current version has worked for me on a couple of occasions.

There may be an easier way to fix this, but if so I don't know what it is. By the way, I don't think the /etc/init.d/tvheadend file is the problem, it always seems to look right even when TVHeadEnd won't start automatically after a reboot.

RE: TVHeadend not auto-starting - Added by Kevin J about 9 years ago

Hi, No, as far as I know I didn't disable anything, installed, rebooted, etc. I am also already on the latest version, v4.0.5.
Can't figure out how to fix it.

RE: TVHeadend not auto-starting - Added by Kevin J about 9 years ago

Anyone else have any suggestions please, diving me nuts having to ssh in each time and do

sudo service tvheadend restart

Kind regards.

RE: TVHeadend not auto-starting - Added by Kevin J about 9 years ago

Is this something to do with being on 15.04 and upstart scripts to systemd?

RE: TVHeadend not auto-starting - Added by Kevin J about 9 years ago

I found an answer. It was indeed to do with ubuntu 15.04 and the upstart scripts and systemd.
I decided to bite the bullet and re-install but with ubuntu 14.04 and then everything worked as expected. Sorted.

RE: [SOLVED] TVHeadend not auto-starting - Added by Quentin D. about 9 years ago

Hi,
I have the same problem on Debian 8 64bit. Do you know how can i fix it ?
Thanks

RE: [SOLVED] TVHeadend not auto-starting - Added by onder tol almost 9 years ago

Try to digit and reboot:

sudo update-rc.d tvheadend defaults

bye

RE: [SOLVED] TVHeadend not auto-starting - Added by Quentin D. almost 9 years ago

Thank you, I'll try that!

RE: [SOLVED] TVHeadend not auto-starting - Added by Quentin D. almost 9 years ago

Hi, I tried your command
# update-rc.d tvheadend defaults
on Debian 8 but it still doesn't start at boot, any ideas?

    (1-9/9)