Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/3] ejabberd: start the daemon as ejabberd user
@ 2015-04-15 15:39 Johan Oudinet
  2015-04-15 15:39 ` [Buildroot] [PATCH 2/3] ejabberd: allow one to change SPOOLDIR location Johan Oudinet
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Johan Oudinet @ 2015-04-15 15:39 UTC (permalink / raw)
  To: buildroot

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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Buildroot] [PATCH 2/3] ejabberd: allow one to change SPOOLDIR location
  2015-04-15 15:39 [Buildroot] [PATCH 1/3] ejabberd: start the daemon as ejabberd user Johan Oudinet
@ 2015-04-15 15:39 ` 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
  2 siblings, 0 replies; 4+ messages in thread
From: Johan Oudinet @ 2015-04-15 15:39 UTC (permalink / raw)
  To: buildroot

By default, ejabberd saves the mnesia database into /var/lib/ejabberd.
Otherwise, one might want to change this location (e.g., if /var/lib is
read-only). Add an option in the init script to offer this possibility.

Signed-off-by: Johan Oudinet <johan.oudinet@gmail.com>
---
 package/ejabberd/S50ejabberd | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/package/ejabberd/S50ejabberd b/package/ejabberd/S50ejabberd
index 925a072..a471078 100644
--- a/package/ejabberd/S50ejabberd
+++ b/package/ejabberd/S50ejabberd
@@ -3,11 +3,16 @@
 # Start/stop ejabberd
 #
 
+NAME=ejabberd
 USER=ejabberd
 RUNDIR=/var/run/ejabberd
+SPOOLDIR=/var/lib/ejabberd
+
+# Read configuration variable file if it is present.
+[ -r /etc/default/$NAME ] && . /etc/default/$NAME
 
 mkrundir() {
-    install -d -o "$USER" -g "$USER" "$RUNDIR"
+    install -d -o "$USER" -g "$USER" "$RUNDIR" "$SPOOLDIR"
 }
 
 # Run ejabberdctl as user $USER.
@@ -19,7 +24,7 @@ case "$1" in
     start)
         mkrundir || exit 1
         echo -n "Starting ejabberd... "
-        ctl start
+        ctl start --spool "$SPOOLDIR"
         ;;
     stop)
         echo -n "Stopping ejabberd... "
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Buildroot] [PATCH 3/3] ejabberd: wait until ejabberd is up and running
  2015-04-15 15:39 [Buildroot] [PATCH 1/3] ejabberd: start the daemon as ejabberd user Johan Oudinet
  2015-04-15 15:39 ` [Buildroot] [PATCH 2/3] ejabberd: allow one to change SPOOLDIR location Johan Oudinet
@ 2015-04-15 15:39 ` Johan Oudinet
  2015-04-19  9:11 ` [Buildroot] [PATCH 1/3] ejabberd: start the daemon as ejabberd user Thomas Petazzoni
  2 siblings, 0 replies; 4+ messages in thread
From: Johan Oudinet @ 2015-04-15 15:39 UTC (permalink / raw)
  To: buildroot

ejabberdctl start returns immediately even if ejabberd is not ready
yet. Add a call to ejabberdctl started just after to wait until the
status says ejabberd is up and running.

Signed-off-by: Johan Oudinet <johan.oudinet@gmail.com>
---
 package/ejabberd/S50ejabberd | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/package/ejabberd/S50ejabberd b/package/ejabberd/S50ejabberd
index a471078..ff38d92 100644
--- a/package/ejabberd/S50ejabberd
+++ b/package/ejabberd/S50ejabberd
@@ -25,6 +25,12 @@ case "$1" in
         mkrundir || exit 1
         echo -n "Starting ejabberd... "
         ctl start --spool "$SPOOLDIR"
+        # Wait until ejabberd is up and running.
+        if ctl started; then
+            echo "done"
+        else
+            echo "failed"
+        fi
         ;;
     stop)
         echo -n "Stopping ejabberd... "
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Buildroot] [PATCH 1/3] ejabberd: start the daemon as ejabberd user
  2015-04-15 15:39 [Buildroot] [PATCH 1/3] ejabberd: start the daemon as ejabberd user Johan Oudinet
  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 ` Thomas Petazzoni
  2 siblings, 0 replies; 4+ messages in thread
From: Thomas Petazzoni @ 2015-04-19  9:11 UTC (permalink / raw)
  To: buildroot

Dear Johan Oudinet,

On Wed, 15 Apr 2015 17:39:05 +0200, Johan Oudinet wrote:
> 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(-)

All three patches applied, thanks.

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-04-19  9:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-15 15:39 [Buildroot] [PATCH 1/3] ejabberd: start the daemon as ejabberd user Johan Oudinet
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox