updated on Thu Jan 12 04:00:44 UTC 2012
[aur-mirror.git] / prosody-hg / prosody.rcd
blobafaf779039d6e02e209cf87f29bd591546fe78c0
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 [ -d /var/run/$daemon_name ] || { mkdir -p /var/run/$daemon_name ; chown prosody:prosody /var/run/prosody; }
23 PID=$(get_pid)
24 if [ -z "$PID" ]; then
25 [ -f $pid_file ] && rm -f $pid_file
26 mkdir -p `dirname $pid_file`
27 prosodyctl start 1>/dev/null 2>/dev/null
28 if [ $? -gt 0 ]; then
29 stat_fail
30 exit 1
31 else
32 add_daemon $daemon_name
33 stat_done
35 else
36 stat_fail
37 printhl "$daemon_name is already running"
38 exit 1
42 stop)
43 stat_busy "Stopping $daemon_name daemon"
44 PID=$(get_pid)
45 if [ ! -z "$PID" ]; then
46 prosodyctl stop 1>/dev/null 2>/dev/null
47 if [ $? -gt 0 ]; then
48 stat_fail
49 exit 1
50 else
51 rm -f $pid_file &> /dev/null
52 rm_daemon $daemon_name
53 stat_done
55 else
56 stat_fail
57 printhl "$daemon_name is not running"
58 exit 1
62 restart)
63 $0 stop
64 $0 start
67 reload)
68 stat_busy "Reloading $daemon_name"
69 PID=$(get_pid)
70 if [ ! -z "$PID" ]; then
71 /bin/kill -HUP $PID 2> /dev/null
72 if [ $? -gt 0 ]; then
73 stat_fail
74 exit 1
75 else
76 stat_done
78 else
79 stat_fail
80 printhl "$daemon_name is not running"
84 status)
85 stat_busy "Checking $daemon_name status";
86 ck_status $daemon_name
90 echo "usage: $0 {start|stop|restart|reload|status}"
91 esac
93 exit 0