From patchwork Sun Oct 7 11:46:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Santos X-Patchwork-Id: 980130 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) 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=none (p=none dis=none) header.from=datacom.com.br 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 42ShYJ6YthzB2xn for ; Sun, 7 Oct 2018 22:47:00 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 8A35581B70; Sun, 7 Oct 2018 11:46:34 +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 B0DOvFa7t+P2; Sun, 7 Oct 2018 11:46:32 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id 347F381AC2; Sun, 7 Oct 2018 11:46:32 +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 E0F4D1BF429 for ; Sun, 7 Oct 2018 11:46:24 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id DE0BE85BF7 for ; Sun, 7 Oct 2018 11:46:24 +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 p5RBC0VfM91F for ; Sun, 7 Oct 2018 11:46:20 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail.datacom.com.br (mx.datacom.ind.br [177.66.5.10]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 0FF2E8592A for ; Sun, 7 Oct 2018 11:46:19 +0000 (UTC) Received: from mail.datacom.com.br (localhost [127.0.0.1]) by mail.datacom.com.br (Postfix) with ESMTPS id 4BA3D1BA0F36; Sun, 7 Oct 2018 08:46:26 -0300 (-03) Received: from localhost (localhost [127.0.0.1]) by mail.datacom.com.br (Postfix) with ESMTP id 3D61E1BA0F05; Sun, 7 Oct 2018 08:46:26 -0300 (-03) Received: from mail.datacom.com.br ([127.0.0.1]) by localhost (mail.datacom.com.br [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id hg6kESXrOtyO; Sun, 7 Oct 2018 08:46:26 -0300 (-03) Received: from p7-1130br.casantos.org (unknown [191.32.32.249]) by mail.datacom.com.br (Postfix) with ESMTPSA id BA1761BA0F34; Sun, 7 Oct 2018 08:46:25 -0300 (-03) From: Carlos Santos To: buildroot@buildroot.org Date: Sun, 7 Oct 2018 08:46:04 -0300 Message-Id: <20181007114605.18153-8-casantos@datacom.com.br> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181007114605.18153-1-casantos@datacom.com.br> References: <20181007114605.18153-1-casantos@datacom.com.br> Subject: [Buildroot] [PATCH v3 7/8] syslog-ng: update S01logging 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: Adam Duskett MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" Reformat and fix syslog-ng startup script for better quality and code style: - Indent with tabs, not spaces. - Do not kill syslog-ng in "reload". Send a SIGHUP signal, instructing it to perform a re-initialization. - Support a configuration file at /etc/default (an example file will be added in forthcomming patch). - Support a configuration variable that completely disables the service and issues a warning message on any invocation. Signed-off-by: Carlos Santos --- Changes v1->v2: - Implement changes suggested by Arnout Vandecappelle. Changes v2->v3: - Include /etc/default/logging, not /etc/default/$DAEMON. - Remove stray 'g' spotted by Chris Packham. --- package/syslog-ng/S01logging | 73 +++++++++++++++++++++++++----------- 1 file changed, 51 insertions(+), 22 deletions(-) diff --git a/package/syslog-ng/S01logging b/package/syslog-ng/S01logging index d7c899a1e3..255ca16660 100644 --- a/package/syslog-ng/S01logging +++ b/package/syslog-ng/S01logging @@ -1,17 +1,42 @@ #!/bin/sh +DAEMON="syslog-ng" +PIDFILE="/var/run/$DAEMON.pid" + +SYSLOG_NG_ARGS="" +ENABLED="yes" + +# shellcheck source=/dev/null +[ -r "/etc/default/logging" ] && . "/etc/default/logging" + +if [ "$ENABLED" != "yes" ]; then + printf '%s is disabled\n' "$DAEMON" + exit 0 +fi + start() { - printf "Starting syslog-ng daemon: " - start-stop-daemon -S -q -p /var/run/syslog-ng.pid \ - -x /usr/sbin/syslog-ng -- --pidfile /var/run/syslog-ng.pid - [ $? = 0 ] && echo "OK" || echo "FAIL" + printf 'Starting %s: ' "$DAEMON" + # shellcheck disable=SC2086 # we need the word splitting + start-stop-daemon -S -q -p "$PIDFILE" -x /usr/sbin/syslog-ng -- $SYSLOG_NG_ARGS + status=$? + if [ "$status" -eq 0 ]; then + echo "OK" + else + echo "FAIL" + fi + return "$status" } stop() { - printf "Stopping syslog-ng daemon: " - start-stop-daemon -K -q -p /var/run/syslog-ng.pid \ - -x /usr/sbin/syslog-ng - [ $? = 0 ] && echo "OK" || echo "FAIL" + printf 'Stopping %s: ' "$DAEMON" + start-stop-daemon -K -q -p "$PIDFILE" + status=$? + if [ "$status" -eq 0 ]; then + echo "OK" + else + echo "FAIL" + fi + return "$status" } restart() { @@ -20,19 +45,23 @@ restart() { start } +# SIGHUP makes syslog-ng reload its configuration +reload() { + printf 'Stopping %s: ' "$DAEMON" + start-stop-daemon -K -s HUP -q -p "$PIDFILE" + status=$? + if [ "$status" -eq 0 ]; then + echo "OK" + else + echo "FAIL" + fi + return "$status" +} + case "$1" in - start) - start - ;; - stop) - stop - ;; - restart|reload) - restart - ;; - *) - echo "Usage: $0 {start|stop|restart}" - exit 1 + start|stop|restart|reload) + "$1";; + *) + echo "Usage: $0 {start|stop|restart|reload}" + exit 1 esac - -exit $?