updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / mpdas / mpdas.rc
blob50f28e8c06d5bbd72692eaf132260ef05799f3bf
1 #!/bin/bash
3 daemon_name=mpdas
5 . /etc/rc.conf
6 . /etc/rc.d/functions
8 get_pid() {
9 pidof -o %PPID /usr/bin/$daemon_name
12 case "$1" in
13 start)
14 stat_busy "Starting $daemon_name daemon"
16 PID=$(get_pid)
17 if [ -z "$PID" ]; then
18 [ -f /var/run/$daemon_name.pid ] && rm -f /var/run/$daemon_name.pid
19 # RUN
20 nohup $daemon_name >> /var/log/mpdas.log &
22 if [ $? -gt 0 ]; then
23 stat_fail
24 exit 1
25 else
26 echo $(get_pid) > /var/run/$daemon_name.pid
27 add_daemon $daemon_name
28 stat_done
30 else
31 stat_fail
32 exit 1
36 stop)
37 stat_busy "Stopping $daemon_name daemon"
38 PID=$(get_pid)
39 # KILL
40 [ ! -z "$PID" ] && kill $PID &> /dev/null
42 if [ $? -gt 0 ]; then
43 stat_fail
44 exit 1
45 else
46 rm -f /var/run/$daemon_name.pid &> /dev/null
47 rm_daemon $daemon_name
48 stat_done
52 restart)
53 $0 stop
54 sleep 3
55 $0 start
58 echo "usage: $0 {start|stop|restart}"
59 esac
60 exit 0