updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / mdd-backend / mdd.rc
blob401f7bdc23a435333424c42fae44262c315254ea
1 #!/bin/bash
3 daemon_name=mdd
4 USER=mdd
6 . /etc/rc.conf
7 . /etc/rc.d/functions
8 [ -f /etc/conf.d/$daemon_name.conf ] && . /etc/conf.d/$daemon_name.conf
10 get_pid() {
11 pidof -o %PPID -x $daemon_name.pl
14 case "$1" in
15 start)
16 stat_busy "Starting $daemon_name daemon"
18 PID=$(get_pid)
19 if [[ -z $PID ]]; then
20 [[ -f /var/run/$daemon_name.pid ]] &&
21 rm -f /var/run/$daemon_name.pid
22 # RUN
23 su $USER -c /usr/bin/vendor_perl/mdd.pl
25 if [[ $? -gt 0 ]]; then
26 stat_fail
27 exit 1
28 else
29 echo $(get_pid) > /var/run/$daemon_name.pid
30 add_daemon $daemon_name
31 stat_done
33 else
34 stat_fail
35 exit 1
39 stop)
40 stat_busy "Stopping $daemon_name daemon"
41 PID=$(get_pid)
42 # KILL
43 [[ -n $PID ]] && kill $PID &> /dev/null
45 if [[ $? -gt 0 ]]; then
46 stat_fail
47 exit 1
48 else
49 rm -f /var/run/$daemon_name.pid &> /dev/null
50 rm_daemon $daemon_name
51 stat_done
55 restart)
56 $0 stop
57 sleep 3
58 $0 start
61 status)
62 stat_busy "Checking $daemon_name status";
63 ck_status $daemon_name
67 echo "usage: $0 {start|stop|restart|status}"
68 esac
70 exit 0
72 # vim:set ts=2 sw=2 et: