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 |
if [ -r /etc/sysconfig/ejabberd ]; then |
21 |
. /etc/sysconfig/ejabberd |
22 |
fi |
23 |
|
24 |
if [ ! "$CONFIG_FILE" ]; then |
25 |
CONFIG_FILE=/etc/ejabberd/ejabberd.cfg |
26 |
fi |
27 |
|
28 |
node=`hostname -s` |
29 |
|
30 |
start() { |
31 |
echo -n $"Starting ejabberd: " |
32 |
if [ "$ULIMIT_MAX_FILES" ]; then |
33 |
ulimit -n $ULIMIT_MAX_FILES |
34 |
fi |
35 |
daemon --user=ejabberd --check=ejabberd \ |
36 |
"erl" "-pa @libdir@/ejabberd/ebin \ |
37 |
-sname ejabberd \ |
38 |
-s ejabberd \ |
39 |
-ejabberd config \\\"$CONFIG_FILE\\\" \ |
40 |
log_path \\\"/var/log/ejabberd/ejabberd.log\\\" \ |
41 |
-sasl sasl_error_logger \\{file,\\\"/var/log/ejabberd/sasl.log\\\"\\} \ |
42 |
-mnesia dir \\\"/var/lib/ejabberd/spool\\\" \ |
43 |
-kernel inetrc \\\"/etc/ejabberd/inetrc\\\" \ |
44 |
-detached" |
45 |
RETVAL=$? |
46 |
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/ejabberd |
47 |
echo |
48 |
return $RETVAL |
49 |
} |
50 |
|
51 |
stop() { |
52 |
# Stop daemons. |
53 |
echo -n "Shutting down ejabberd: " |
54 |
/sbin/runuser -s /bin/bash - ejabberd -c "erl -pa @libdir@/ejabberd/ebin -noinput -sname ejabberdctl -s ejabberd_ctl -extra ejabberd@$node stop" && success || failure |
55 |
RETVAL=$? |
56 |
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/ejabberd |
57 |
echo |
58 |
return $RETVAL |
59 |
} |
60 |
|
61 |
restart() { |
62 |
stop |
63 |
sleep 5 |
64 |
start |
65 |
} |
66 |
|
67 |
# See how we were called. |
68 |
case "$1" in |
69 |
start) |
70 |
start |
71 |
;; |
72 |
stop) |
73 |
stop |
74 |
;; |
75 |
restart) |
76 |
restart |
77 |
;; |
78 |
force-reload) |
79 |
restart |
80 |
;; |
81 |
condrestart) |
82 |
[ -f /var/lock/subsys/ejabberd ] && restart || : |
83 |
;; |
84 |
try-restart) |
85 |
[ -f /var/lock/subsys/ejabberd ] && restart || : |
86 |
;; |
87 |
status) |
88 |
/sbin/runuser -s /bin/bash - ejabberd -c "erl -pa @libdir@/ejabberd/ebin -noinput -sname ejabberdctl -s ejabberd_ctl -extra ejabberd@$node status" |
89 |
;; |
90 |
*) |
91 |
echo "Usage: ejabberd {start|stop|restart|force-reload|condrestart|try-restart|status}" |
92 |
exit 1 |
93 |
esac |
94 |
|
95 |
exit $? |
96 |
|
97 |
|