updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / mythtv-git / mythbackend.rc
blob410e8de4176d31f034c732f73685fa6ba6879f54
1 #!/bin/bash
3 . /etc/rc.conf
4 . /etc/rc.d/functions
6 # Default values to use if none are supplied in the config file.
8 # Running mythbackend as non-root requires you to ensure that audio/video
9 # devices used for recording have suitable user permissions. One way
10 # to achieve this is to modify existing or create new udev rules which
11 # assign these devices to a non-root group with rw permissions and add
12 # your mythbackend user to that group. Be aware that console.perms can
13 # also affect device permissions and may need additional configuration.
14 # Running as non-root may also introduce increased process latency.
16 # User who should start the mythbackend processes
17 MBE_USER='root'
19 # Startup options for mythbackend
20 MBE_OPTIONS=''
22 # Name of mythbackend log file
23 LOG_FILE='/var/log/mythbackend.log'
25 # Logging options for mythbackend (empty means '-v important,general')
26 LOG_OPTS=''
28 ###############################################################################
30 CONFIG_FILE=/etc/conf.d/mythbackend
31 PIDFILE=/var/run/mythbackend.pid
33 if [[ -f ${CONFIG_FILE} ]]; then
34 . ${CONFIG_FILE}
37 pid="$(cat ${PIDFILE} 2>/dev/null || pidof mythbackend)";
39 # fix FS#11890
40 mbe_user_home="$(getent passwd ${MBE_USER}|cut -d : -f 6)"
42 case "$1" in
43 start)
44 stat_busy "Starting MythTV Backend"
46 # already running ?
47 if [[ "${pid}" -gt 0 ]] && kill -0 "${pid}"; then
48 stat_fail
49 exit 1;
50 fi
51 touch ${PIDFILE} ${LOG_FILE}
52 chown "$MBE_USER" ${PIDFILE} ${LOG_FILE}
53 if su "$MBE_USER" -c "HOME=${mbe_user_home} mythbackend \
54 --daemon \
55 --logfile $LOG_FILE $LOG_OPTS \
56 --pidfile ${PIDFILE} $MBE_OPTIONS";
57 then
58 add_daemon mythbackend
59 stat_done
60 else
61 stat_fail
65 stop)
66 stat_busy "Stopping MythTV Backend"
67 if [[ "${pid}" -gt 0 ]] && kill $pid &>/dev/null; then
68 rm_daemon mythbackend
69 stat_done
70 rm ${PIDFILE} 2>/dev/null
71 else
72 stat_fail
75 restart)
76 $0 stop
77 $0 start
80 echo "usage: $0 {start|stop|restart}"
81 esac
82 exit 0