updated on Thu Jan 12 04:00:44 UTC 2012
[aur-mirror.git] / prosody-devel / prosody.rcd
blobccde0b09219fbe59d1ddb5f6d09c90ee589f8913
1 #!/bin/bash
3 daemon_name=prosody
4 pid_file=/var/run/$daemon_name/$daemon_name.pid
6 source /etc/rc.conf
7 source /etc/rc.d/functions
9 get_pid() {
10 if [ -f $pid_file ]; then
11 /bin/kill -0 $(cat $pid_file)
12 if [ $? == 0 ]; then
13 cat $pid_file
18 case "$1" in
19 start)
20 stat_busy "Starting $daemon_name daemon"
22 PID=$(get_pid)
23 if [ -z "$PID" ]; then
24 [ -f $pid_file ] && rm -f $pid_file
25 prosodyctl start > /dev/null
26 if [ $? -gt 0 ]; then
27 stat_fail
28 exit 1
29 else
30 add_daemon $daemon_name
31 stat_done
33 else
34 stat_fail
35 printhl "$daemon_name is already running"
36 exit 1
40 stop)
41 stat_busy "Stopping $daemon_name daemon"
42 PID=$(get_pid)
43 if [ ! -z "$PID" ]; then
44 prosodyctl stop > /dev/null
45 if [ $? -gt 0 ]; then
46 stat_fail
47 exit 1
48 else
49 rm -f $pid_file &> /dev/null
50 rm_daemon $daemon_name
51 stat_done
53 else
54 stat_fail
55 printhl "$daemon_name is not running"
56 exit 1
60 restart)
61 $0 stop
62 $0 start
65 reload)
66 stat_busy "Reloading $daemon_name"
67 PID=$(get_pid)
68 if [ ! -z "$PID" ]; then
69 /bin/kill -HUP $PID 2> /dev/null
70 if [ $? -gt 0 ]; then
71 stat_fail
72 exit 1
73 else
74 stat_done
76 else
77 stat_fail
78 printhl "$daemon_name is not running"
82 status)
83 stat_busy "Checking $daemon_name status";
84 ck_status $daemon_name
88 echo "usage: $0 {start|stop|restart|reload|status}"
89 esac
91 exit 0