From patchwork Wed Oct 23 18:05:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Santos X-Patchwork-Id: 1182338 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=busybox.net (client-ip=140.211.166.133; helo=hemlock.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Vs+gfxIp"; dkim-atps=neutral Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46yywG1mlXz9sCJ for ; Thu, 24 Oct 2019 05:05:33 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 27B5B88179; Wed, 23 Oct 2019 18:05:30 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id REkU7+YCTkCz; Wed, 23 Oct 2019 18:05:27 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id 62B228816A; Wed, 23 Oct 2019 18:05:27 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 753831BF48D for ; Wed, 23 Oct 2019 18:05:25 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 5907122115 for ; Wed, 23 Oct 2019 18:05:25 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bvz18MSJdXvz for ; Wed, 23 Oct 2019 18:05:24 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-qt1-f195.google.com (mail-qt1-f195.google.com [209.85.160.195]) by silver.osuosl.org (Postfix) with ESMTPS id 67E45207EF for ; Wed, 23 Oct 2019 18:05:24 +0000 (UTC) Received: by mail-qt1-f195.google.com with SMTP id g50so19440704qtb.4 for ; Wed, 23 Oct 2019 11:05:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=cGZkkcL6YTfFK2hGIvgHrtmM3/0sr3X+IIzXEqfgglY=; b=Vs+gfxIpKqGQG/mRYQkOXmZidtqUG2d8BmXzhULFjztuIo1Z7L1zZzTGrQX5EMgq9T ovLviSSDpbi9fa1AD+kZ/n5NvWKgSPO2VYxXAzFuwYPQyw2XK60ewzy0AtXRf8hrTcHF NvA/vgk705zxoDp7rW7uDhRlT7iOgLhb9nO3fAaaBB6PzKLuzYaqz45HWkd6u8+FykrV 6bbbqa68ag32ldr6vs3v0BjxyxC4ZfOnu3jhk+C1pMDL+JmY2P9p0QI9J4K55F6Ig6HE BQM9OfuJZqoIKwokmdrp3TOXRiq5JMsmXcVMsebivzPmMGOPMVBYHxXgEn2kbaNeI0VK 881w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=cGZkkcL6YTfFK2hGIvgHrtmM3/0sr3X+IIzXEqfgglY=; b=aFg5b1Dg5s9aku9ogJfJiwTQyr/iPqEbOoJ3ukPyjvsneoz2lAOscllEq38YuyBqrx cjTWpIhfOFmaMdTf8av+ILcrU+9Dz41W6kr1d/MEjrAvJ2nTVOsnsqMxvPWooAmhapbm vGcDmmKZm+bf9ztilJqHjo+riKv9xzrFbj3tpWaLUVcoaYrO686LfqBmAI2JQj6PCTMs 803Nsdbh9ITrK9dX2xMXUlyPQm8Wd3Y1O5LdnQ1tkWf+UBhE3Ra1pO7x7G1uWJT70HOS ytviym5qWsKI5QR7aVSvKnTF6BJjWYZdjTevEi/LjIDs6IWYurDFZgdOGrsgoGuRUC0D JKTw== X-Gm-Message-State: APjAAAWuaa5IE6230+L9z3DjDKWbEBhtwGlsoa8NbdMUIbUXQzILRDAW 31gKU/b2iQW9Q/h+M5QExxPDf44M X-Google-Smtp-Source: APXvYqzyz7Dav0EX3Ngl6JbASIiL3aZRW10fT/Vuc9myiAiVFUM5d4YHiPFsQfoPIyXdbB/ag+Xvnw== X-Received: by 2002:a0c:b303:: with SMTP id s3mr10143572qve.172.1571853923010; Wed, 23 Oct 2019 11:05:23 -0700 (PDT) Received: from casantos.remote.csb ([177.156.131.32]) by smtp.gmail.com with ESMTPSA id t17sm19163798qtt.57.2019.10.23.11.05.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2019 11:05:21 -0700 (PDT) From: unixmania@gmail.com To: buildroot@buildroot.org Date: Wed, 23 Oct 2019 15:05:12 -0300 Message-Id: <20191023180512.21400-1-unixmania@gmail.com> X-Mailer: git-send-email 2.18.1 Subject: [Buildroot] [PATCH] package/acpid: refactor init script X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Carlos Santos MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" From: Carlos Santos Adapt the format to the current template, used in other init scripts. Move the one socond delay in restart to stop, giving acpid time to send dying gasp to syslog. Users willing to add start arguments can set the ACPID_ARGS variable in /etc/default/acpid instead of rewriting the init script. Signed-off-by: Carlos Santos --- package/acpid/S02acpid | 65 +++++++++++++++++++++++++++++++----------- 1 file changed, 48 insertions(+), 17 deletions(-) diff --git a/package/acpid/S02acpid b/package/acpid/S02acpid index e8d3661674..9017d508ff 100644 --- a/package/acpid/S02acpid +++ b/package/acpid/S02acpid @@ -1,22 +1,53 @@ #!/bin/sh -case "$1" in - start) - printf "Starting acpid: " - start-stop-daemon -S -q -m -b -p /var/run/acpid.pid --exec /usr/sbin/acpid -- -n - [ $? = 0 ] && echo "OK" || echo "FAIL" - ;; - stop) - printf "Stopping acpid: " - start-stop-daemon -K -q -p /var/run/acpid.pid - [ $? = 0 ] && echo "OK" || echo "FAIL" - ;; - restart) - "$0" stop +DAEMON="acpid" +EXEC="/usr/sbin/$DAEMON" +PIDFILE="/var/run/$DAEMON.pid" + +ACPID_ARGS="" + +# shellcheck source=/dev/null +[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON" + +start() { + printf 'Starting %s: ' "$DAEMON" + # shellcheck disable=SC2086 # we need the word splitting + start-stop-daemon -S -q -p "$PIDFILE" -x "$EXEC" \ + -- -n $ACPID_ARGS + status=$? + if [ "$status" -eq 0 ]; then + echo "OK" + else + echo "FAIL" + fi + return "$status" +} + +stop() { + printf 'Stopping %s: ' "$DAEMON" + start-stop-daemon -K -q -p "$PIDFILE" -x "$EXEC" + status=$? + if [ "$status" -eq 0 ]; then + # Give acpid time to send dying gasp to syslog sleep 1 - "$0" start - ;; + echo "OK" + else + echo "FAIL" + fi + return "$status" +} + +restart() { + stop + start +} + +case "$1" in + start|stop|restart) + "$1";; + reload) + restart;; *) - echo "Usage: $0 {start|stop|restart}" - ;; + echo "Usage: $0 {start|stop|restart|reload}" + exit 1 esac