Fedora init.d mythjobqueue
From MythTV Official Wiki
| Author | unknown |
| Description | Starts the mythjobqueue process as a daemon after X and MySQL have started, in runlevel 5. This allows jobs to be processed without manual intervention. |
| Supports |
#!/bin/bash
#
# Rename this file to:
#
# /etc/rc.d/init.d/mythjobqueue
#
###############################################################################
#
# chkconfig: - 86 14
# pidfile: /var/run/mythjobqueue.pid
# description: Starts the mythjobqueue process as a daemon after X and MySQL \
# have started, in runlevel 5. This allows jobs to be processed \
# without manual intervention.
# processname: mythjobqueue
# config: /etc/sysconfig/mythjobqueue
#
###############################################################################
#
# 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
#
###############################################################################
# Default values to use if none are supplied in the config file.
# Running mythjobqueue as non-root may require you to ensure that the
# recording directories and files have suitable user permissions. If
# all recording file access is done via streaming from the backends,
# this is not necessary.
#
# User who should start the mythjobqueue processes
MBE_USER='root'
# Directory holding the mythjobqueue binary (empty means autodetect)
MBE_DIR=''
# Name of mythjobqueue binary
MBE_PROG='mythjobqueue'
# Startup options for mythjobqueue
MBE_OPTIONS=''
# Directory holding the mythjobqueue log file
LOG_DIR='/var/log/mythtv'
# Name of mythjobqueue log file
LOG_FILE='mythjobqueue.log'
# Logging options for mythjobqueue (empty means '-v important,general')
LOG_OPTS=''
###############################################################################
# Source function library.
. /etc/init.d/functions
# Source config file if available
if [ -f "/etc/sysconfig/mythjobqueue" ]; then
. /etc/sysconfig/mythjobqueue
fi
# Find the executable
if [ ! -z "$MBE_DIR" ]; then
MBE_BIN="$MBE_DIR/$MBE_PROG"
else
MBE_BIN=`which "$MBE_PROG" 2>/dev/null`
if [ ! -f "$MBE_BIN" ]; then
if [ -f "/usr/bin/$MBE_PROG" ]; then
MBE_BIN="/usr/bin/$MBE_PROG"
elif [ -f "/usr/local/bin/$MBE_PROG" ]; then
MBE_BIN="/usr/local/bin/$MBE_PROG"
fi
fi
fi
# Error messages
if [ ! -f "$MBE_BIN" ]; then
echo "Cannot find $MBE_PROG executable"
exit 1
elif [ ! -x "$MBE_BIN" ]; then
echo "$MBE_PROG is not executable"
exit 1
elif [ ! -d "$LOG_DIR" ]; then
echo "Log directory does not exist"
exit 1
fi
# Initialize the return variable
RETVAL=0
###############################################################################
#
# Start the process
#
start() {
# Already running?
if [ -f "/var/lock/subsys/$MBE_PROG" ]; then
echo "$MBE_PROG is already running."
return 0
fi
# Start
echo -n $"Starting $MBE_PROG: "
touch "/var/run/$MBE_PROG.pid"
chown "$MBE_USER":"$MBE_USER" "/var/run/$MBE_PROG.pid"
daemon --user "$MBE_USER" "$MBE_BIN" \
--daemon \
--logfile "$LOG_DIR/$LOG_FILE" "$LOG_OPTS" \
--pidfile "/var/run/$MBE_PROG.pid" \
$MBE_OPTIONS
RETVAL=$?
[ $RETVAL = 0 ] && touch /var/lock/subsys/$MBE_PROG
echo
return $RETVAL
}
#
# Stop the process
#
stop() {
echo -n $"Stopping $MBE_PROG: "
killproc "$MBE_PROG"
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/${MBE_PROG} /var/run/${MBE_PROG}.pid
echo
return $RETVAL
}
#
# Restart
#
restart() {
stop
start
}
###############################################################################
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
condrestart)
if [ -f "/var/lock/subsys/$MBE_PROG" ]; then
restart
fi
;;
status)
status "$MBE_BIN"
RETVAL=$?
;;
*)
echo "Usage: $0 {start|stop|restart|condrestart|status}"
exit 1
esac
exit $RETVAL
#!/bin/bash # # Rename this file to: # # /etc/sysconfig/mythjobqueue # ############################################################################### # # 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 mythjobqueue startup script, which is usually # located in /etc/rc.d/init.d/mythjobqueue # # 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/mythjobqueue). # # To override defaults, uncomment the relevant variable definition and # edit as required. # # # User who should start the mythjobqueue processes # # Running mythjobqueue as non-root may require you to ensure that the # recording directories and files have suitable user permissions. This # is not necessary if all recordings are streamed from the backends. # # MBE_USER='root' # # Directory holding the mythjobqueue binary (empty means autodetect). # # MBE_DIR='' # # Name of mythjobqueue binary. # # MBE_PROG='mythjobqueue' # # Other startup options for mythjobqueue (see 'mythjobqueue --help' for a list). # # MBE_OPTIONS='' # # Directory holding the mythjobqueue log file # # LOG_DIR='/var/log/mythtv' # # Name of mythjobqueue log file. # # NOTE: If you are running as non-root take care to ensure the mythjobqueue user # has permission to write to this log file. # # LOG_FILE='mythjobqueue.log' # # Logging options for mythjobqueue (see 'mythjobqueue -v help' for a list) # # LOG_OPTS=''