Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH 02/11] ejabberd: simplify init script by patching ejabberdctl
Date: Sat, 11 Jul 2015 12:30:51 +0200	[thread overview]
Message-ID: <20150711123051.664507d5@free-electrons.com> (raw)
In-Reply-To: <1436349264-11797-3-git-send-email-johan.oudinet@gmail.com>

Dear Johan Oudinet,

On Wed,  8 Jul 2015 11:54:15 +0200, Johan Oudinet wrote:
> Let a user modify environment variables used in ejabberdctl by loading
> a default configuration file.
> 
> Signed-off-by: Johan Oudinet <johan.oudinet@gmail.com>
> ---
>  package/ejabberd/0009-fix-ejabberdctl.patch | 21 +++++++++++++++++++
>  package/ejabberd/S50ejabberd                | 32 +++++++++++++----------------
>  2 files changed, 35 insertions(+), 18 deletions(-)
>  create mode 100644 package/ejabberd/0009-fix-ejabberdctl.patch
> 
> diff --git a/package/ejabberd/0009-fix-ejabberdctl.patch b/package/ejabberd/0009-fix-ejabberdctl.patch
> new file mode 100644
> index 0000000..9ae23ac
> --- /dev/null
> +++ b/package/ejabberd/0009-fix-ejabberdctl.patch
> @@ -0,0 +1,21 @@
> +Description: fix ejabberdctl
> + Change default values so ejabberdctl run commands as ejabberd user
> + Also add a way for the user to change default values.
> +Signed-off-by: Johan Oudinet <johan.oudinet@gmail.com>
> +
> +diff --git a/ejabberdctl.template b/ejabberdctl.template
> +index 79f4438..df0abba 100755
> +--- a/ejabberdctl.template
> ++++ b/ejabberdctl.template
> +@@ -14,7 +14,10 @@ SCRIPT_DIR=`cd ${0%/*} && pwd`
> + ERL={{erl}}
> + IEX={{bindir}}/iex
> + EPMD={{bindir}}/epmd
> +-INSTALLUSER={{installuser}}
> ++INSTALLUSER=ejabberd

So this makes the patch Buildroot specific. Why isn't the
{{installuser}} properly replaced by the "right" value at install time?

> ++
> ++# Read default configuration file if present.
> ++[ ! -r /etc/default/ejabberd ] || . /etc/default/ejabberd

I don't really understand why we are loading this default file here and
in the init script itself. Who is installing this /etc/default/ejabberd
file? What does it contain?

> + 
> + # check the proper system user is used if defined
> + if [ "$INSTALLUSER" != "" ] ; then
> diff --git a/package/ejabberd/S50ejabberd b/package/ejabberd/S50ejabberd
> index ff38d92..2161ead 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"

And we're reading the /etc/default/ejabberd file here as well.

Can you give some more details about what is going on?

>  
> +# 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

This change doesn't seem to be related.

>          "$0" start
>          ;;
>      live)
>          mkrundir || exit 1
> -        ctl live
> +        "$CTL" live
>          ;;
>      *)
>          echo "Usage: $0 {start|stop|status|restart|force-reload|live}"

Thanks,

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

  reply	other threads:[~2015-07-11 10:30 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-08  9:54 [Buildroot] [PATCH 00/11] Bump ejabberd version to 15.06 Johan Oudinet
2015-07-08  9:54 ` [Buildroot] [PATCH 01/11] ejabberd: bump to version 15.06 Johan Oudinet
2015-07-08  9:54 ` [Buildroot] [PATCH 02/11] ejabberd: simplify init script by patching ejabberdctl Johan Oudinet
2015-07-11 10:30   ` Thomas Petazzoni [this message]
2015-07-14  9:52     ` Johan Oudinet
2015-07-19 21:09       ` Thomas Petazzoni
2015-07-08  9:54 ` [Buildroot] [PATCH 03/11] ejabberd: fix package version Johan Oudinet
2015-07-11 10:31   ` Thomas Petazzoni
2015-07-14 10:02     ` Johan Oudinet
2015-07-08  9:54 ` [Buildroot] [PATCH 04/11] erlang-p1-utils: bump to version 1bf99f9 Johan Oudinet
2015-07-08  9:54 ` [Buildroot] [PATCH 05/11] erlang-p1-cache-tab: bump to version f7ea12b Johan Oudinet
2015-07-08  9:54 ` [Buildroot] [PATCH 06/11] erlang-p1-tls: bump to version b070004 Johan Oudinet
2015-07-08  9:54 ` [Buildroot] [PATCH 07/11] erlang-p1-stringprep: bump to version 3c64023 Johan Oudinet
2015-07-08  9:54 ` [Buildroot] [PATCH 08/11] erlang-p1-xml: bump to version 2c61083 Johan Oudinet
2015-07-08  9:54 ` [Buildroot] [PATCH 09/11] erlang-p1-stun: bump to version a3dce07 Johan Oudinet
2015-07-08  9:54 ` [Buildroot] [PATCH 10/11] erlang-p1-sip: bump to version fd3e461 Johan Oudinet
2015-07-08  9:54 ` [Buildroot] [PATCH 11/11] erlang-p1-yaml: bump to version e1f081e Johan Oudinet
2015-07-11 10:28 ` [Buildroot] [PATCH 00/11] Bump ejabberd version to 15.06 Thomas Petazzoni
2015-07-14  9:10   ` Johan Oudinet

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=20150711123051.664507d5@free-electrons.com \
    --to=thomas.petazzoni@free-electrons.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