diff options
Diffstat (limited to 'community/mythtv/mythbackend.rc')
-rw-r--r-- | community/mythtv/mythbackend.rc | 105 |
1 files changed, 48 insertions, 57 deletions
diff --git a/community/mythtv/mythbackend.rc b/community/mythtv/mythbackend.rc index 410e8de41..2b3c2d52e 100644 --- a/community/mythtv/mythbackend.rc +++ b/community/mythtv/mythbackend.rc @@ -2,81 +2,72 @@ . /etc/rc.conf . /etc/rc.d/functions +. /etc/profile +############################################################################### # Default values to use if none are supplied in the config file. - -# Running mythbackend as non-root requires you to ensure that audio/video -# devices used for recording have suitable user permissions. One way -# to achieve this is to modify existing or create new udev rules which -# assign these devices to a non-root group with rw permissions and add -# your mythbackend user to that group. Be aware that console.perms can -# also affect device permissions and may need additional configuration. -# Running as non-root may also introduce increased process latency. # -# User who should start the mythbackend processes +# User who should start the mythbackend process MBE_USER='root' # Startup options for mythbackend -MBE_OPTIONS='' +MBE_OPTS='' -# Name of mythbackend log file -LOG_FILE='/var/log/mythbackend.log' +# Directory holding the mythbackend log file +LOG_PATH='/var/log/mythtv' -# Logging options for mythbackend (empty means '-v important,general') +# Logging options for mythbackend LOG_OPTS='' - ############################################################################### CONFIG_FILE=/etc/conf.d/mythbackend PIDFILE=/var/run/mythbackend.pid -if [[ -f ${CONFIG_FILE} ]]; then - . ${CONFIG_FILE} +if [[ -r "$CONFIG_FILE" ]]; then + . "$CONFIG_FILE" fi -pid="$(cat ${PIDFILE} 2>/dev/null || pidof mythbackend)"; - -# fix FS#11890 -mbe_user_home="$(getent passwd ${MBE_USER}|cut -d : -f 6)" +PID="$(cat "$PIDFILE" 2> /dev/null || pidof mythbackend)" +export HOME="$(getent passwd "$MBE_USER" | cut -d : -f 6)" case "$1" in - start) - stat_busy "Starting MythTV Backend" + start) + stat_busy "Starting MythTV Backend" + + if [[ "$PID" -gt 0 ]] && kill -0 "$PID"; then + stat_fail + exit 0 + fi + + touch "$PIDFILE" + chown "$MBE_USER" "$PIDFILE" "$LOG_PATH" - # already running ? - if [[ "${pid}" -gt 0 ]] && kill -0 "${pid}"; then - stat_fail - exit 1; - fi - touch ${PIDFILE} ${LOG_FILE} - chown "$MBE_USER" ${PIDFILE} ${LOG_FILE} - if su "$MBE_USER" -c "HOME=${mbe_user_home} mythbackend \ - --daemon \ - --logfile $LOG_FILE $LOG_OPTS \ - --pidfile ${PIDFILE} $MBE_OPTIONS"; - then - add_daemon mythbackend - stat_done - else - stat_fail - fi - ;; - - stop) - stat_busy "Stopping MythTV Backend" - if [[ "${pid}" -gt 0 ]] && kill $pid &>/dev/null; then - rm_daemon mythbackend - stat_done - rm ${PIDFILE} 2>/dev/null - else - stat_fail - fi - ;; - restart) - $0 stop - $0 start - ;; - *) - echo "usage: $0 {start|stop|restart}" + MBE_CMD="/usr/bin/mythbackend --daemon \ + --logpath "$LOG_PATH" $LOG_OPTS \ + --pidfile "$PIDFILE" $MBE_OPTS" + if su "$MBE_USER" -c "$MBE_CMD"; then + add_daemon mythbackend + stat_done + else + stat_fail + fi + ;; + stop) + stat_busy "Stopping MythTV Backend" + if [[ "$PID" -gt 0 ]] && kill "$PID" &> /dev/null; then + rm_daemon mythbackend + stat_done + rm -f "$PIDFILE" + else + stat_fail + fi + ;; + restart) + "$0" stop + "$0" start + ;; + *) + echo "usage: $0 (start|stop|restart)" + ;; esac exit 0 |