Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Johan Oudinet <johan.oudinet@gmail.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH 1/3] ejabberd: start the daemon as ejabberd user
Date: Wed, 15 Apr 2015 17:39:05 +0200	[thread overview]
Message-ID: <1429112347-17009-1-git-send-email-johan.oudinet@gmail.com> (raw)

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>
---
 package/ejabberd/S50ejabberd | 28 ++++++++++++++++++++--------
 1 file changed, 20 insertions(+), 8 deletions(-)

diff --git a/package/ejabberd/S50ejabberd b/package/ejabberd/S50ejabberd
index 2656307..925a072 100644
--- a/package/ejabberd/S50ejabberd
+++ b/package/ejabberd/S50ejabberd
@@ -7,29 +7,41 @@ USER=ejabberd
 RUNDIR=/var/run/ejabberd
 
 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
     start)
-	mkrundir
-        echo "Starting ejabberd..."
-        ejabberdctl start
+        mkrundir || exit 1
+        echo -n "Starting ejabberd... "
+        ctl start
         ;;
     stop)
         echo -n "Stopping ejabberd... "
-        ejabberdctl stop > /dev/null
-        if [ $? -eq 3 ] || ejabberdctl stopped; then
+        ctl stop > /dev/null
+        if [ $? -eq 3 ] || ctl stopped; then
             echo "OK"
         else
             echo "failed"
         fi
         ;;
-    restart|reload)
+    status)
+        ctl status
+        ;;
+    restart|force-reload)
         "$0" stop
         "$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
 esac
-- 
2.1.0

             reply	other threads:[~2015-04-15 15:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-15 15:39 Johan Oudinet [this message]
2015-04-15 15:39 ` [Buildroot] [PATCH 2/3] ejabberd: allow one to change SPOOLDIR location Johan Oudinet
2015-04-15 15:39 ` [Buildroot] [PATCH 3/3] ejabberd: wait until ejabberd is up and running Johan Oudinet
2015-04-19  9:11 ` [Buildroot] [PATCH 1/3] ejabberd: start the daemon as ejabberd user Thomas Petazzoni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1429112347-17009-1-git-send-email-johan.oudinet@gmail.com \
    --to=johan.oudinet@gmail.com \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox