aboutsummaryrefslogtreecommitdiff
path: root/src/mythtv
diff options
context:
space:
mode:
authorAdrian C. (anrxc) <anrxc@sysphere.org>2012-11-25 21:24:58 +0100
committerAdrian C. (anrxc) <anrxc@sysphere.org>2012-11-25 21:24:58 +0100
commit16262790cb6ddacf6c632625cc865e03b1b8671f (patch)
tree09898d65deef518380915ecdc7575756c9ca8595 /src/mythtv
parent7bb1499a7cd539f714bb7f603d7fc0a38fd8a963 (diff)
downloadrcdscripts-16262790cb6ddacf6c632625cc865e03b1b8671f.tar.xz
rcdscripts: import first snapshot of rc.d scripts as of 11.25.20122012.11.25
In 30 days these scripts will start dissapearing from official Arch Linux packages. This is an attempt to conserve them, and keep sysvinit usable.
Diffstat (limited to 'src/mythtv')
-rwxr-xr-xsrc/mythtv/mythbackend.rc73
1 files changed, 73 insertions, 0 deletions
diff --git a/src/mythtv/mythbackend.rc b/src/mythtv/mythbackend.rc
new file mode 100755
index 0000000..488b4cb
--- /dev/null
+++ b/src/mythtv/mythbackend.rc
@@ -0,0 +1,73 @@
+#!/bin/bash
+
+. /etc/rc.conf
+. /etc/rc.d/functions
+. /etc/profile
+
+###############################################################################
+# Default values to use if none are supplied in the config file.
+#
+# User who should start the mythbackend process
+MBE_USER='mythtv'
+
+# Startup options for mythbackend
+MBE_OPTS=''
+
+# Directory holding the mythbackend log file
+LOG_PATH='/var/log/mythtv'
+
+# Logging options for mythbackend
+LOG_OPTS=''
+###############################################################################
+
+CONFIG_FILE=/etc/conf.d/mythbackend
+PIDFILE=/var/run/mythbackend.pid
+
+if [[ -r "$CONFIG_FILE" ]]; then
+ . "$CONFIG_FILE"
+fi
+
+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"
+
+ if [[ "$PID" -gt 0 ]] && kill -0 "$PID"; then
+ stat_fail
+ exit 0
+ fi
+
+ touch "$PIDFILE"
+ chown "$MBE_USER" "$PIDFILE" "$LOG_PATH"
+
+ 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