LSB init.d mythbackend
From MythTV Official Wiki
| Author | unknown |
| Description | mythbackend init.d start script for Linux Standard Base distributions |
| Supports |
#!/bin/sh
### BEGIN INIT INFO
# Provides: mythbackend
# Required-Start: $network $remote_fs
# Required-Stop:
# Should-Start: mysql
# Default-Start: 2 3 5
# Default-Stop:
# Description: Start the MythTV backend
### END INIT INFO
# Shell functions sourced from /etc/rc.status:
# rc_check check and set local and overall rc status
# rc_status check and set local and overall rc status
# rc_status -v ditto but be verbose in local rc status
# rc_status -v -r ditto and clear the local rc status
# rc_failed set local and overall rc status to failed
# rc_failed <num> set local and overall rc status to <num>
# rc_reset clear local rc status (overall remains)
# rc_exit exit appropriate to overall rc status
. /etc/rc.status
# First reset status of this service
rc_reset
unset MBE
logdir=/var/log
if test -x /usr/bin/mythbackend
then
MBE=/usr/bin/mythbackend
basedir=/usr
bindir=/usr/bin
datadir=/tmp
elif test -x /usr/local/bin/mythbackend
then
MBE=/usr/local/bin/mythbackend
basedir=/usr/local
bindir=/usr/local/bin
datadir=/tmp
elif test -x /opt/mythtv/bin/mythbackend
then
MBE=/opt/mythtv/bin/mythbackend
basedir=/opt/mythtv
bindir=/opt/mythtv/bin
datadir=/opt/mythtv
fi
# Check for existence of needed config file and read it
backend_CONFIG=/etc/sysconfig/mythbackend
test -r $backend_CONFIG || exit 6
. $backend_CONFIG
test "$MBE" || { echo "Unable to locate a mythbackend to execute"; rc_failed 5; rc_status -v; rc_exit; }
if test -z "$pid_file"
then
pid_file=$datadir/mythbackend.`/bin/hostname`.pid
else
case "$pid_file" in
/* ) ;;
* ) pid_file="$datadir/$pid_file" ;;
esac
fi
mode=$1 # start or stop
# Safeguard (relative paths, core dumps..)
cd $basedir
case "$1" in
start)
# exit gracefully, if we are already running
checkproc $MBE && echo -n "Starting service Myth Backend" && \
rc_status -v && rc_exit
test -x $MBE || { echo "$MBE does not exist"; rc_failed 5; rc_status -v; rc_exit; }
echo "Starting service MythTV Backend"
startproc $MBE -l $logdir/mythbackend.log 2>> $logdir/mythbackend.error.log &
# Remember status and be verbose
rc_status -v
;;
stop)
echo "Shutting down service MythTV Backend"
killproc -p $pid_file -TERM $MBE
# Remember status and be verbose
rc_status -v
;;
try-restart)
## Stop the service and if this succeeds (i.e. the
## service was running before), start it again.
## Note: try-restart is not (yet) part of LSB (as of 0.7.5)
$0 status >/dev/null && $0 restart
# Remember status and be quiet
rc_status
;;
restart|force-reload)
echo "Restarting service MythTV Backend"
$0 stop
$0 start
rc_status
;;
reload)
echo -n "Reloading service MythTV Backend"
killproc -p $pid_file -HUP $MBE
touch $pid_file
rc_status -v
;;
check|status)
echo -n "Checking for service MythTV BackendL: "
## Check status with checkproc(8), if process is running
## checkproc will return with exit status 0.
# Status has a slightly different for the status command:
# 0 - service running
# 1 - service dead, but /var/run/ pid file exists
# 2 - service dead, but /var/lock/ lock file exists
# 3 - service not running
# NOTE: checkproc returns LSB compliant status values.
checkproc $MBE
rc_status -v
;;
*)
echo "Usage: $0 {start|stop|status|reload|restart|try-restart|force-reload}"
exit 1
;;
esac
rc_exit
#!/bin/bash # # Rename this file to: # # /etc/sysconfig/mythbackend # ############################################################################### # # Copyright (c) by the MythTV Development Team. # # Derived from work by: # # Michael Thomson <linux at m-thomson dot net> # Stu Tomlinson <stu at nosnilmot dot com> # Axel Thimm <axel.thimm at atrpms dot net> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### # # Config variables for the mythbackend startup script, which is usually # located in /etc/rc.d/init.d/mythbackend # # When the startup script is executed, it sources this file if it exists, # otherwise it will fall back on default values. # # Leave variables commented out to use default values in init script # (/etc/rc.d/init.d/mythbackend). # # To override defaults, uncomment the relevant variable definition and # edit as required. # # # User who should start the mythbackend processes # # 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. # # MBE_USER='root' # # Directory holding the mythbackend binary (empty means autodetect). # # MBE_DIR='' # # Name of mythbackend binary. # # MBE_PROG='mythbackend' # # Other startup options for mythbackend (see 'mythbackend --help' for a list). # # MBE_OPTIONS='' # # Directory holding the mythbackend log file # # LOG_DIR='/var/log/mythtv' # # Name of mythbackend log file. # # NOTE: If you are running as non-root take care to ensure the mythbackend user # has permission to write to this log file. # # LOG_FILE='mythbackend.log' # # Logging options for mythbackend (see 'mythbackend -v help' for a list) # # LOG_OPTS=''