[arch-commits] Commit in mythtv/trunk (mythbackend)
Juergen Hoetzel
juergen at archlinux.org
Sun Nov 8 23:05:15 UTC 2009
Date: Sunday, November 8, 2009 @ 18:05:14
Author: juergen
Revision: 58560
clean rewrite of initscript (based on fedora initscript)
Modified:
mythtv/trunk/mythbackend
-------------+
mythbackend | 101 +++++++++++++++++++++++++++++++++++++++++-----------------
1 file changed, 72 insertions(+), 29 deletions(-)
Modified: mythbackend
===================================================================
--- mythbackend 2009-11-08 23:00:11 UTC (rev 58559)
+++ mythbackend 2009-11-08 23:05:14 UTC (rev 58560)
@@ -3,35 +3,78 @@
. /etc/rc.conf
. /etc/rc.d/functions
-PID=`pidof -o %PPID /usr/bin/mythbackend`
+# 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
+MBE_USER='root'
+
+# Startup options for mythbackend
+MBE_OPTIONS=''
+
+# Name of mythbackend log file
+LOG_FILE='/var/log/mythbackend.log'
+
+# Logging options for mythbackend (empty means '-v important,general')
+LOG_OPTS=''
+
+###############################################################################
+
+CONFIG_FILE=/etc/conf.d/mythbackend
+PIDFILE=/var/run/mythbackend.pid
+
+if [[ -f ${CONFIG_FILE} ]]; then
+ . ${CONFI_FILE}
+fi
+
+pid="$(cat ${PIDFILE} 2>/dev/null || pidof mythbackend)";
+
case "$1" in
- start)
- stat_busy "Starting MythTV Backend"
- [ -z "$PID" ] && /usr/bin/mythbackend -d -l /var/log/mythbackend.log -v important
- if [ $? -gt 0 ]; then
- stat_fail
- else
- echo $PID > /var/run/mythbackend.pid
- add_daemon mythbackend
- stat_done
- fi
- ;;
- stop)
- stat_busy "Stopping MythTV Backend"
- [ ! -z "$PID" ] && kill $PID &>/dev/null
- if [ $? -gt 0 ]; then
- stat_fail
- else
- rm_daemon mythbackend
- stat_done
- fi
- ;;
- restart)
- $0 stop
- sleep 1s
- $0 start
- ;;
- *)
- echo "usage: $0 {start|stop|restart}"
+ start)
+ stat_busy "Starting MythTV Backend"
+
+ # already running ?
+ if [[ "${pid}" -gt 0 ]] && kill -0 "${pid}"; then
+ stat_fail
+ exit 1;
+ fi
+ touch "/var/run/mythbackend.pid"
+ chown "$MBE_USER" ${PIDFILE}
+
+ if su "$MBE_USER" -c "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}"
esac
exit 0
More information about the arch-commits
mailing list