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>
This commit is contained in:
Johan Oudinet 2015-04-15 17:39:05 +02:00 committed by Thomas Petazzoni
parent 7e66b9905d
commit 0972c9c10b

View File

@ -7,29 +7,41 @@ USER=ejabberd
RUNDIR=/var/run/ejabberd RUNDIR=/var/run/ejabberd
mkrundir() { mkrundir() {
install -d -o $USER -g $USER $RUNDIR install -d -o "$USER" -g "$USER" "$RUNDIR"
}
# Run ejabberdctl as user $USER.
ctl() {
su $USER -c "ejabberdctl $*"
} }
case "$1" in case "$1" in
start) start)
mkrundir mkrundir || exit 1
echo "Starting ejabberd..." echo -n "Starting ejabberd... "
ejabberdctl start ctl start
;; ;;
stop) stop)
echo -n "Stopping ejabberd... " echo -n "Stopping ejabberd... "
ejabberdctl stop > /dev/null ctl stop > /dev/null
if [ $? -eq 3 ] || ejabberdctl stopped; then if [ $? -eq 3 ] || ctl stopped; then
echo "OK" echo "OK"
else else
echo "failed" echo "failed"
fi fi
;; ;;
restart|reload) status)
ctl status
;;
restart|force-reload)
"$0" stop "$0" stop
"$0" start "$0" start
;; ;;
live)
mkrundir || exit 1
ctl live
;;
*) *)
echo "Usage: $0 {start|stop|restart}" echo "Usage: $0 {start|stop|status|restart|force-reload|live}"
exit 1 exit 1
esac esac