From patchwork Wed Jul 8 09:54:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Oudinet X-Patchwork-Id: 492822 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ozlabs.org (Postfix) with ESMTP id 0459A140772 for ; Wed, 8 Jul 2015 19:55:10 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=TwZAoea7; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 1A6BDA41DC; Wed, 8 Jul 2015 09:55:08 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id k9UZLpqgioJd; Wed, 8 Jul 2015 09:55:06 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id 3F262A4024; Wed, 8 Jul 2015 09:55:03 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 8E48E1C28A1 for ; Wed, 8 Jul 2015 09:55:00 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 8AB14A3DF6 for ; Wed, 8 Jul 2015 09:55:00 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id usw7uqp1n7Yv for ; Wed, 8 Jul 2015 09:55:00 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wg0-f53.google.com (mail-wg0-f53.google.com [74.125.82.53]) by fraxinus.osuosl.org (Postfix) with ESMTPS id C4AD1A3C95 for ; Wed, 8 Jul 2015 09:54:59 +0000 (UTC) Received: by wgck11 with SMTP id k11so190992350wgc.0 for ; Wed, 08 Jul 2015 02:54:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6WWH+xov8BXqsrdu5XLZ01wMJj6/2CPisI2rgbbn318=; b=TwZAoea7IaHr1SHM7MsXPSUr3yezwAda5eay4LIWH8yDevxVL+LcuLHRFnFHPTgW1/ KO4Zwa0glxdz+spfjwuegqPZ7tVpQeaXN3ue0C4GYActf0C+SsjnYBi+lUOTMQ097ziP mMzJTVrNerZKLvCWFq0Cex5wOonH0R+0Aw8v5lUjW340smQkxpeiiPJ9ZZBJxitkJTpm JnCUbsINek8Dmgf7wjb7+LzzD0r6N8PUre2qYuk3Zw3h6/vb5P6WtbE5pDZ7hkfBmaMV Akc1v3f3vVZpM7HAST7dQO8jykqFb8aNKV0UpSwJT0KipEmLOAoUK7gn4XPsePH3ST81 7qxA== X-Received: by 10.180.86.163 with SMTP id q3mr74576284wiz.75.1436349298481; Wed, 08 Jul 2015 02:54:58 -0700 (PDT) Received: from localhost.localdomain ([193.51.194.209]) by smtp.gmail.com with ESMTPSA id ny7sm2013288wic.11.2015.07.08.02.54.57 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 08 Jul 2015 02:54:57 -0700 (PDT) From: Johan Oudinet To: buildroot@buildroot.org Date: Wed, 8 Jul 2015 11:54:15 +0200 Message-Id: <1436349264-11797-3-git-send-email-johan.oudinet@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1436349264-11797-1-git-send-email-johan.oudinet@gmail.com> References: <1436349264-11797-1-git-send-email-johan.oudinet@gmail.com> Subject: [Buildroot] [PATCH 02/11] ejabberd: simplify init script by patching ejabberdctl X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" Let a user modify environment variables used in ejabberdctl by loading a default configuration file. Signed-off-by: Johan Oudinet --- 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 + +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 ++ ++# Read default configuration file if present. ++[ ! -r /etc/default/ejabberd ] || . /etc/default/ejabberd + + # 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" +# 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}"