1 |
#!/bin/bash |
2 |
# |
3 |
# ejabberd Start and stop ejabberd. |
4 |
|
5 |
# chkconfig: - 40 60 |
6 |
# description: ejabberd |
7 |
# processname: ejabberd |
8 |
# pidfile: /var/run/ejabberd.pid |
9 |
|
10 |
### BEGIN INIT INFO |
11 |
# Provides: ejabberd |
12 |
# Required-Start: network |
13 |
# Required-Stop: network |
14 |
# Short-Description: Start and stop ejabberd |
15 |
# Description: A distributed, fault-tolerant Jabber/XMPP server |
16 |
### END INIT INFO |
17 |
|
18 |
. /etc/rc.d/init.d/functions |
19 |
|
20 |
node=`hostname | cut -d. -f1` |
21 |
|
22 |
start() { |
23 |
echo -n $"Starting ejabberd: " |
24 |
daemon --user=ejabberd --check=ejabberd \ |
25 |
"erl" "-pa @libdir@/ejabberd-@version@/ebin \ |
26 |
-sname ejabberd \ |
27 |
-s ejabberd \ |
28 |
-ejabberd config \\\"/etc/ejabberd/ejabberd.cfg\\\" \ |
29 |
log_path \\\"/var/log/ejabberd/ejabberd.log\\\" \ |
30 |
-sasl sasl_error_logger \\{file,\\\"/var/log/ejabberd/sasl.log\\\"\\} \ |
31 |
-mnesia dir \\\"/var/lib/ejabberd/spool\\\" \ |
32 |
-kernel inetrc \\\"/etc/ejabberd/inetrc\\\" \ |
33 |
-detached" |
34 |
RETVAL=$? |
35 |
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/ejabberd |
36 |
echo |
37 |
return $RETVAL |
38 |
} |
39 |
|
40 |
stop() { |
41 |
# Stop daemons. |
42 |
echo -n "Shutting down ejabberd: " |
43 |
/sbin/runuser -s /bin/bash - ejabberd -c "erl -pa @libdir@/ejabberd-@version@/ebin -noinput -sname ejabberdctl -s ejabberd_ctl -extra ejabberd@$node stop" && success || failure |
44 |
RETVAL=$? |
45 |
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/ejabberd |
46 |
echo |
47 |
return $RETVAL |
48 |
} |
49 |
|
50 |
restart() { |
51 |
stop |
52 |
sleep 5 |
53 |
start |
54 |
} |
55 |
|
56 |
# See how we were called. |
57 |
case "$1" in |
58 |
start) |
59 |
start |
60 |
;; |
61 |
stop) |
62 |
stop |
63 |
;; |
64 |
restart) |
65 |
restart |
66 |
;; |
67 |
force-reload) |
68 |
restart |
69 |
;; |
70 |
condrestart) |
71 |
[ -f /var/lock/subsys/ejabberd ] && restart || : |
72 |
;; |
73 |
try-restart) |
74 |
[ -f /var/lock/subsys/ejabberd ] && restart || : |
75 |
;; |
76 |
status) |
77 |
/sbin/runuser -s /bin/bash - ejabberd -c "erl -pa @libdir@/ejabberd-@version@/ebin -noinput -sname ejabberdctl -s ejabberd_ctl -extra ejabberd@$node status" |
78 |
;; |
79 |
*) |
80 |
echo "Usage: ejabberd {start|stop|restart|force-reload|condrestart|try-restart|status}" |
81 |
exit 1 |
82 |
esac |
83 |
|
84 |
exit $? |
85 |
|
86 |
|