aboutsummaryrefslogtreecommitdiff
path: root/package/ejabberd/S50ejabberd
diff options
context:
space:
mode:
authorGravatar Johan Oudinet <johan.oudinet@gmail.com>2015-07-08 11:54:15 +0200
committerGravatar Thomas Petazzoni <thomas.petazzoni@free-electrons.com>2015-07-19 23:06:10 +0200
commit4ef5bcde94ed7689d0c69f7077da398afb090c7e (patch)
treea73d835ef20ed9c4217a6917ac8cd25b277f7569 /package/ejabberd/S50ejabberd
parent390e778db22d9d9b2feca36faf29326d62717b9c (diff)
downloadbuildroot-4ef5bcde94ed7689d0c69f7077da398afb090c7e.tar.gz
buildroot-4ef5bcde94ed7689d0c69f7077da398afb090c7e.tar.bz2
ejabberd: simplify init script by patching ejabberdctl
Let a user modify environment variables used in ejabberdctl by loading a default configuration file. Signed-off-by: Johan Oudinet <johan.oudinet@gmail.com> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Diffstat (limited to 'package/ejabberd/S50ejabberd')
-rw-r--r--package/ejabberd/S50ejabberd32
1 files changed, 14 insertions, 18 deletions
diff --git a/package/ejabberd/S50ejabberd b/package/ejabberd/S50ejabberd
index ff38d9224d..2161eadca8 100644
--- a/package/ejabberd/S50ejabberd
+++ b/package/ejabberd/S50ejabberd
@@ -3,30 +3,26 @@
# Start/stop ejabberd
#
-NAME=ejabberd
-USER=ejabberd
+CTL=/usr/sbin/ejabberdctl
+DEFAULT=/etc/default/ejabberd
+INSTALLUSER=ejabberd
RUNDIR=/var/run/ejabberd
-SPOOLDIR=/var/lib/ejabberd
-# Read configuration variable file if it is present.
-[ -r /etc/default/$NAME ] && . /etc/default/$NAME
+# Read default configuration file if present.
+[ -r "$DEFAULT" ] && . "$DEFAULT"
+# Create RUNDIR.
mkrundir() {
- install -d -o "$USER" -g "$USER" "$RUNDIR" "$SPOOLDIR"
-}
-
-# Run ejabberdctl as user $USER.
-ctl() {
- su $USER -c "ejabberdctl $*"
+ install -d -o "$INSTALLUSER" -g "$INSTALLUSER" "$RUNDIR"
}
case "$1" in
start)
mkrundir || exit 1
echo -n "Starting ejabberd... "
- ctl start --spool "$SPOOLDIR"
+ "$CTL" start
# Wait until ejabberd is up and running.
- if ctl started; then
+ if "$CTL" started; then
echo "done"
else
echo "failed"
@@ -34,23 +30,23 @@ case "$1" in
;;
stop)
echo -n "Stopping ejabberd... "
- ctl stop > /dev/null
- if [ $? -eq 3 ] || ctl stopped; then
+ "$CTL" stop > /dev/null
+ if [ $? -eq 3 ] || "$CTL" stopped; then
echo "OK"
else
echo "failed"
fi
;;
status)
- ctl status
+ "$CTL" status
;;
restart|force-reload)
- "$0" stop
+ "$0" stop || true
"$0" start
;;
live)
mkrundir || exit 1
- ctl live
+ "$CTL" live
;;
*)
echo "Usage: $0 {start|stop|status|restart|force-reload|live}"