PKGBUILDs/community/mythtv/mythbackend.rc

74 lines
1.6 KiB
Text
Raw Normal View History

2012-02-01 04:48:03 +00:00
#!/bin/bash
. /etc/rc.conf
. /etc/rc.d/functions
2012-04-12 12:25:04 +00:00
. /etc/profile
2012-02-01 04:48:03 +00:00
2012-04-12 12:25:04 +00:00
###############################################################################
2012-02-01 04:48:03 +00:00
# Default values to use if none are supplied in the config file.
#
2012-04-12 12:25:04 +00:00
# User who should start the mythbackend process
2012-02-01 04:48:03 +00:00
MBE_USER='root'
# Startup options for mythbackend
2012-04-12 12:25:04 +00:00
MBE_OPTS=''
2012-02-01 04:48:03 +00:00
2012-04-12 12:25:04 +00:00
# Directory holding the mythbackend log file
LOG_PATH='/var/log/mythtv'
2012-02-01 04:48:03 +00:00
2012-04-12 12:25:04 +00:00
# Logging options for mythbackend
2012-02-01 04:48:03 +00:00
LOG_OPTS=''
###############################################################################
CONFIG_FILE=/etc/conf.d/mythbackend
PIDFILE=/var/run/mythbackend.pid
2012-04-12 12:25:04 +00:00
if [[ -r "$CONFIG_FILE" ]]; then
. "$CONFIG_FILE"
2012-02-01 04:48:03 +00:00
fi
2012-04-12 12:25:04 +00:00
PID="$(cat "$PIDFILE" 2> /dev/null || pidof mythbackend)"
export HOME="$(getent passwd "$MBE_USER" | cut -d : -f 6)"
2012-02-01 04:48:03 +00:00
case "$1" in
2012-04-12 12:25:04 +00:00
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"
2012-02-01 04:48:03 +00:00
2012-04-12 12:25:04 +00:00
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)"
;;
2012-02-01 04:48:03 +00:00
esac
exit 0