2015-01-12 10:32:20 +01:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Start/stop ejabberd
|
|
|
|
#
|
|
|
|
|
2015-04-15 17:39:06 +02:00
|
|
|
NAME=ejabberd
|
2015-01-12 10:32:20 +01:00
|
|
|
USER=ejabberd
|
|
|
|
RUNDIR=/var/run/ejabberd
|
2015-04-15 17:39:06 +02:00
|
|
|
SPOOLDIR=/var/lib/ejabberd
|
|
|
|
|
|
|
|
# Read configuration variable file if it is present.
|
|
|
|
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
|
2015-01-12 10:32:20 +01:00
|
|
|
|
|
|
|
mkrundir() {
|
2015-04-15 17:39:06 +02:00
|
|
|
install -d -o "$USER" -g "$USER" "$RUNDIR" "$SPOOLDIR"
|
2015-04-15 17:39:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Run ejabberdctl as user $USER.
|
|
|
|
ctl() {
|
|
|
|
su $USER -c "ejabberdctl $*"
|
2015-01-12 10:32:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
start)
|
2015-04-15 17:39:05 +02:00
|
|
|
mkrundir || exit 1
|
|
|
|
echo -n "Starting ejabberd... "
|
2015-04-15 17:39:06 +02:00
|
|
|
ctl start --spool "$SPOOLDIR"
|
2015-04-15 17:39:07 +02:00
|
|
|
# Wait until ejabberd is up and running.
|
|
|
|
if ctl started; then
|
|
|
|
echo "done"
|
|
|
|
else
|
|
|
|
echo "failed"
|
|
|
|
fi
|
2015-01-12 10:32:20 +01:00
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
echo -n "Stopping ejabberd... "
|
2015-04-15 17:39:05 +02:00
|
|
|
ctl stop > /dev/null
|
|
|
|
if [ $? -eq 3 ] || ctl stopped; then
|
2015-01-12 10:32:20 +01:00
|
|
|
echo "OK"
|
|
|
|
else
|
|
|
|
echo "failed"
|
|
|
|
fi
|
|
|
|
;;
|
2015-04-15 17:39:05 +02:00
|
|
|
status)
|
|
|
|
ctl status
|
|
|
|
;;
|
|
|
|
restart|force-reload)
|
2015-01-12 10:32:20 +01:00
|
|
|
"$0" stop
|
|
|
|
"$0" start
|
|
|
|
;;
|
2015-04-15 17:39:05 +02:00
|
|
|
live)
|
|
|
|
mkrundir || exit 1
|
|
|
|
ctl live
|
|
|
|
;;
|
2015-01-12 10:32:20 +01:00
|
|
|
*)
|
2015-04-15 17:39:05 +02:00
|
|
|
echo "Usage: $0 {start|stop|status|restart|force-reload|live}"
|
2015-01-12 10:32:20 +01:00
|
|
|
exit 1
|
|
|
|
esac
|