fb1e02ed35
ejabberdctl start returns immediately even if ejabberd is not ready yet. Add a call to ejabberdctl started just after to wait until the status says ejabberd is up and running. Signed-off-by: Johan Oudinet <johan.oudinet@gmail.com> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
59 lines
1.1 KiB
Bash
59 lines
1.1 KiB
Bash
#!/bin/sh
|
|
#
|
|
# Start/stop ejabberd
|
|
#
|
|
|
|
NAME=ejabberd
|
|
USER=ejabberd
|
|
RUNDIR=/var/run/ejabberd
|
|
SPOOLDIR=/var/lib/ejabberd
|
|
|
|
# Read configuration variable file if it is present.
|
|
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
|
|
|
|
mkrundir() {
|
|
install -d -o "$USER" -g "$USER" "$RUNDIR" "$SPOOLDIR"
|
|
}
|
|
|
|
# Run ejabberdctl as user $USER.
|
|
ctl() {
|
|
su $USER -c "ejabberdctl $*"
|
|
}
|
|
|
|
case "$1" in
|
|
start)
|
|
mkrundir || exit 1
|
|
echo -n "Starting ejabberd... "
|
|
ctl start --spool "$SPOOLDIR"
|
|
# Wait until ejabberd is up and running.
|
|
if ctl started; then
|
|
echo "done"
|
|
else
|
|
echo "failed"
|
|
fi
|
|
;;
|
|
stop)
|
|
echo -n "Stopping ejabberd... "
|
|
ctl stop > /dev/null
|
|
if [ $? -eq 3 ] || ctl stopped; then
|
|
echo "OK"
|
|
else
|
|
echo "failed"
|
|
fi
|
|
;;
|
|
status)
|
|
ctl status
|
|
;;
|
|
restart|force-reload)
|
|
"$0" stop
|
|
"$0" start
|
|
;;
|
|
live)
|
|
mkrundir || exit 1
|
|
ctl live
|
|
;;
|
|
*)
|
|
echo "Usage: $0 {start|stop|status|restart|force-reload|live}"
|
|
exit 1
|
|
esac
|