Project

General

Profile

Actions

Bug #1776

closed

Upstart Configuration is uses "expect" stanza incorrectly

Added by Diego Rivera almost 12 years ago. Updated almost 12 years ago.

Status:
Rejected
Priority:
Normal
Assignee:
-
Category:
General
Target version:
-
Start date:
2013-08-04
Due date:
% Done:

0%

Estimated time:
Found in version:
3.4.27
Affected Versions:

Description

The upstart configuration in the latest TVH package (3.4.27~gfbda802~quantal) uses the "expect fork" stanza incorrectly based on the behavior of the tvheadend executable. The result is that "stop tvheadend" will hang, as may any subsequent "start tvheadend" invocations. This causes the machine to not reboot or suspend promptly under certain common circumstances.

TVH doesn't use fork() the way upstart expects it to within the context of the "expect XXX" stanzas. Therefore, its use should be abandoned. The existing upstart configuration file should be replaced by the following:

# tvheadend - DVB/IPTV streaming server
#
# Tvheadend is a TV streaming server for Linux supporting DVB, ATSC, IPTV,
# and Analog video (V4L) as input sources.

description "Tvheadend DVB/IPTV streaming server" 
author      "Adam Sutton <dev@adamsutton.me.uk>" 

start on (local-filesystems and net-device-up and started udev-finish)
stop  on starting shutdown

setuid hts
setgid video
respawn

script
  [ -r /etc/default/tvheadend ] && . /etc/default/tvheadend
  if [ "$TVH_ENABLED" != "1" ] ; then
    stop
    exit 0
  fi

  CONF="$(readlink -f ~hts/.hts/tvheadend)" 
  [ -n "$TVH_CONF_DIR"  ] && CONF="$TVH_CONF_DIR" 

  ARGS="-c ${CONF}" 
  [ -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" 
  [ "$TVH_DEBUG" = "1"  ] && ARGS="$ARGS -s" 

  [ ! -z "$TVH_DELAY" ] && sleep $TVH_DELAY

  exec tvheadend $ARGS $TVH_ARGS
end script

This new configuration has the drawback that the user TVH runs as is no longer configurable in /etc/default/tvheadend (due to the use of setuid/setgid stanzas which are non-dynamic in upstart). The username is also hardcoded in the declaration of the CONF variable (~hts/...). If anyone (XBMCbuntu) is interested in changing this out, they'll have to edit the script directly. Or simply follow the standard pattern of letting TVH run as the hts user.

Cheers!

Actions

Also available in: Atom PDF