updated on Thu Jan 19 12:17:07 UTC 2012
[aur-mirror.git] / vdr-devel / rc-runvdr
blob07d9c43c260b2e4da232eb4a4616f3019c7745cc
1 #!/bin/bash
3 daemon_name="runvdr"
4 pid_file="/var/run/$daemon_name.pid"
5 daemon_full_path="/usr/bin/$daemon_name"
6 daemon_args=""
8 . /etc/rc.conf
9 . /etc/rc.d/functions
10 #. /etc/conf.d/$daemon_name.conf
12 get_pid() {
13 pidof -x -o %PPID $daemon_full_path
16 case "$1" in
17 start)
18 stat_busy "Starting $daemon_name daemon"
20 PID=$(get_pid)
21 if [ -z "$PID" ]; then
22 [ -f /var/run/$daemon_name.pid ] && rm -f /var/run/$daemon_name.pid
23 # RUN
24 $daemon_full_path $daemon_args &
26 if [ $? -gt 0 ]; then
27 stat_fail
28 exit 1
29 else
30 # Create a PID file if the daemon did not
31 if [ ! -f "$pid_file" ]; then
32 echo $(get_pid) > $pid_file
34 add_daemon $daemon_name
35 stat_done
37 else
38 stat_fail
39 exit 1
43 stop)
44 stat_busy "Stopping $daemon_name daemon"
45 PID=$(get_pid)
46 # KILL
47 [ ! -z "$PID" ] && kill $PID &> /dev/null
48 # The runvdr script may not kill vdr on exit so do it here
49 killall --quiet --wait vdr
51 if [ $? -gt 0 ]; then
52 stat_fail
53 exit 1
54 else
55 rm -f $pid_file &> /dev/null
56 rm_daemon $daemon_name
57 stat_done
61 restart)
62 $0 stop
63 sleep 3
64 $0 start
67 status)
68 stat_busy "Checking $daemon_name status";
69 ck_status $daemon_name
73 echo "usage: $0 {start|stop|restart|status}"
74 esac
76 exit 0