kumquat-buildroot/package/ejabberd/S50ejabberd
Johan Oudinet 0972c9c10b ejabberd: start the daemon as ejabberd user
ejabberd.mk creates an ejabberd user but the init script was starting
the xmpp server as root user. This patch fixes it by invoking
ejabberctl from a "su ejabberd -c" command.

Signed-off-by: Johan Oudinet <johan.oudinet@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2015-04-19 11:11:07 +02:00

48 lines
823 B
Bash

#!/bin/sh
#
# Start/stop ejabberd
#
USER=ejabberd
RUNDIR=/var/run/ejabberd
mkrundir() {
install -d -o "$USER" -g "$USER" "$RUNDIR"
}
# Run ejabberdctl as user $USER.
ctl() {
su $USER -c "ejabberdctl $*"
}
case "$1" in
start)
mkrundir || exit 1
echo -n "Starting ejabberd... "
ctl start
;;
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