From patchwork Sun Oct 7 11:45:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Santos X-Patchwork-Id: 980122 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.137; helo=fraxinus.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 fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42ShXf0GNzzB2xn for ; Sun, 7 Oct 2018 22:46:25 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 05DA6858F7; 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 pj9WQeHEyNcq; Sun, 7 Oct 2018 11:46:23 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id 4E6D285936; Sun, 7 Oct 2018 11:46:23 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 476381BF429 for ; Sun, 7 Oct 2018 11:46:20 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 451C5874AA for ; Sun, 7 Oct 2018 11:46:20 +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 tb1iDCG2rFbF for ; Sun, 7 Oct 2018 11:46:17 +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 hemlock.osuosl.org (Postfix) with ESMTPS id 03C1087489 for ; Sun, 7 Oct 2018 11:46:16 +0000 (UTC) Received: from mail.datacom.com.br (localhost [127.0.0.1]) by mail.datacom.com.br (Postfix) with ESMTPS id F12B71BA0F2F; Sun, 7 Oct 2018 08:46:22 -0300 (-03) Received: from localhost (localhost [127.0.0.1]) by mail.datacom.com.br (Postfix) with ESMTP id DDBCA1BA0F05; Sun, 7 Oct 2018 08:46:22 -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 J1oat3Cfs2IV; Sun, 7 Oct 2018 08:46:22 -0300 (-03) Received: from p7-1130br.casantos.org (unknown [191.32.32.249]) by mail.datacom.com.br (Postfix) with ESMTPSA id 5BFDB1BA0F26; Sun, 7 Oct 2018 08:46:22 -0300 (-03) From: Carlos Santos To: buildroot@buildroot.org Date: Sun, 7 Oct 2018 08:45:58 -0300 Message-Id: <20181007114605.18153-2-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 1/8] busybox: 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 syslogd/klogd startup script for better quality and code style: - Detect and report start/stop errors (previous version ignored them and always reported OK). - Use a separate function for restart. - Implement reload as restart. - Support a configuration variable that completely disables the service and issues a warning message on any invocation. Signed-off-by: Carlos Santos Reviewed-by: Matt Weber Tested-by: Matt Weber --- Changes v1->v2 - Implement suggestions made by Nicolas Cavallari and Arnout Vandecappelle --- package/busybox/S01logging | 82 +++++++++++++++++++++++++------------- 1 file changed, 54 insertions(+), 28 deletions(-) diff --git a/package/busybox/S01logging b/package/busybox/S01logging index fcb3e7d236..ddd27bba9a 100644 --- a/package/busybox/S01logging +++ b/package/busybox/S01logging @@ -1,40 +1,66 @@ #!/bin/sh -# -# Start logging -# -SYSLOGD_ARGS=-n -KLOGD_ARGS=-n -[ -r /etc/default/logging ] && . /etc/default/logging +DAEMON="logging" +SPIDFILE="/var/run/syslogd.pid" +KPIDFILE="/var/run/klogd.pid" +SYSLOGD_ARGS="" +KLOGD_ARGS="" +ENABLED="yes" + +# shellcheck source=/dev/null +[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON" + +if [ "$ENABLED" != "yes" ]; then + printf '%s is disabled\n' "$DAEMON" + exit 0 +fi + +# BusyBox' syslogd and klogd do not create pidfiles, so use "-m" to instruct +# start-stop-daemon to create them. This also means that we must pass "-n" to +# sylogd and klogd in the command line. start() { - printf "Starting logging: " - start-stop-daemon -b -S -q -m -p /var/run/syslogd.pid --exec /sbin/syslogd -- $SYSLOGD_ARGS - start-stop-daemon -b -S -q -m -p /var/run/klogd.pid --exec /sbin/klogd -- $KLOGD_ARGS - echo "OK" + printf 'Starting %s: ' "$DAEMON" + status=0 + # shellcheck disable=SC2086 # we need the word splitting + start-stop-daemon -b -S -q -m -p "$SPIDFILE" -x /sbin/syslogd -- -n $SYSLOGD_ARGS || status=$? + start-stop-daemon -b -S -q -m -p "$KPIDFILE" -x /sbin/klogd -- -n $KLOGD_ARGS || status=$? + if [ "$status" -eq 0 ]; then + echo "OK" + else + echo "FAIL" + fi + return "$status" } stop() { - printf "Stopping logging: " - start-stop-daemon -K -q -p /var/run/syslogd.pid - start-stop-daemon -K -q -p /var/run/klogd.pid - echo "OK" + printf 'Stopping %s: ' "$DAEMON" + status=0 + start-stop-daemon -K -q -p "$SPIDFILE" || status=$? + [ "$status" -eq 0 ] && rm -f "$SPIDFILE" + start-stop-daemon -K -q -p "$KPIDFILE" || status=$? + [ "$status" -eq 0 ] && rm -f "$KPIDFILE" + if [ "$status" -eq 0 ]; then + echo "OK" + else + echo "FAIL" + fi + return "$status" } -case "$1" in - start) - start - ;; - stop) - stop - ;; - restart|reload) +restart() { stop + sleep 1 start - ;; - *) - echo "Usage: $0 {start|stop|restart|reload}" - exit 1 -esac +} -exit $? +case "$1" in + start|stop|restart) + "$1";; + reload) + # Restart, since there is no true "reload" feature. + restart;; + *) + echo "Usage: $0 {start|stop|restart|reload}" + exit 1 +esac From patchwork Sun Oct 7 11:45:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Santos X-Patchwork-Id: 980123 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 42ShXg3qqgzB3sq for ; Sun, 7 Oct 2018 22:46:27 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id EBF7387489; Sun, 7 Oct 2018 11:46:24 +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 9eBBP9Nbh9qx; Sun, 7 Oct 2018 11:46:20 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id 9355A874AA; Sun, 7 Oct 2018 11:46:20 +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 6BDD01BF429 for ; Sun, 7 Oct 2018 11:46:19 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 68D8B220C2 for ; Sun, 7 Oct 2018 11:46:19 +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 UMuPZfWwv6F5 for ; Sun, 7 Oct 2018 11:46:16 +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 silver.osuosl.org (Postfix) with ESMTPS id 9340621561 for ; Sun, 7 Oct 2018 11:46:16 +0000 (UTC) Received: from mail.datacom.com.br (localhost [127.0.0.1]) by mail.datacom.com.br (Postfix) with ESMTPS id 865421BA0F1B; Sun, 7 Oct 2018 08:46:23 -0300 (-03) Received: from localhost (localhost [127.0.0.1]) by mail.datacom.com.br (Postfix) with ESMTP id 70B681BA0F05; Sun, 7 Oct 2018 08:46:23 -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 jzgBqZwhX-Zt; Sun, 7 Oct 2018 08:46:23 -0300 (-03) Received: from p7-1130br.casantos.org (unknown [191.32.32.249]) by mail.datacom.com.br (Postfix) with ESMTPSA id E3F9C1BA0F24; Sun, 7 Oct 2018 08:46:22 -0300 (-03) From: Carlos Santos To: buildroot@buildroot.org Date: Sun, 7 Oct 2018 08:45:59 -0300 Message-Id: <20181007114605.18153-3-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 2/8] busybox: add logging configuration file 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" Provide a template to help users to customize syslogd and klogd without editting the startup script. syslogd options worth to configure are remote logging (-R), rotation (-s, -b) and minimal priority level (-l). klogd minimal priority level (-c) can be configured too, preventing non-critical kernel messages from appearing on the console. This file is also useful as an example for init script authors. Signed-off-by: Carlos Santos Tested-by: Matt Weber --- Changes v1->v2 - Implement suggestions made by Nicolas Cavallari and Arnout Vandecappelle Changes v2->v3 - Add reference to documentation, as suggested by Matt Weber. --- package/busybox/busybox.mk | 2 ++ package/busybox/etc.default.logging | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 package/busybox/etc.default.logging diff --git a/package/busybox/busybox.mk b/package/busybox/busybox.mk index 757086592f..91131c0012 100644 --- a/package/busybox/busybox.mk +++ b/package/busybox/busybox.mk @@ -252,6 +252,8 @@ define BUSYBOX_INSTALL_LOGGING_SCRIPT then \ $(INSTALL) -m 0755 -D package/busybox/S01logging \ $(TARGET_DIR)/etc/init.d/S01logging; \ + $(INSTALL) -m 0644 -D package/busybox/etc.default.logging \ + $(TARGET_DIR)/etc/default/logging; \ fi endef diff --git a/package/busybox/etc.default.logging b/package/busybox/etc.default.logging new file mode 100644 index 0000000000..5e52eff985 --- /dev/null +++ b/package/busybox/etc.default.logging @@ -0,0 +1,17 @@ +# +# /etc/default/logging (busybox version) +# +# Online documentation of syslogd and klogd is available at +# +# https://busybox.net/downloads/BusyBox.html +# + +# Use SYSLOGD_ARGS to pass additional arguments to syslogd (e.g. for log +# rotation). +# SYSLOGD_ARGS="" # (default value) + +# Use KLOGD_ARGS to pass additional arguments to klogd. +# KLOGD_ARGS="" # (default value) + +# Uncomment the line below to disable this service +# ENABLED="no" From patchwork Sun Oct 7 11:46:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Santos X-Patchwork-Id: 980126 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 42ShXk6MP6zB3sq for ; Sun, 7 Oct 2018 22:46:30 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 0AD9F874E8; Sun, 7 Oct 2018 11:46:26 +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 56F-SIarYwen; Sun, 7 Oct 2018 11:46:25 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id 8404D874EA; Sun, 7 Oct 2018 11:46:25 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 66EEA1BF429 for ; Sun, 7 Oct 2018 11:46:21 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 6366A864CB for ; Sun, 7 Oct 2018 11:46:21 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ohGj8G5SqFSI for ; Sun, 7 Oct 2018 11:46:18 +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 whitealder.osuosl.org (Postfix) with ESMTPS id 16C8C866F0 for ; Sun, 7 Oct 2018 11:46:17 +0000 (UTC) Received: from mail.datacom.com.br (localhost [127.0.0.1]) by mail.datacom.com.br (Postfix) with ESMTPS id 2082B1BA0F24; Sun, 7 Oct 2018 08:46:24 -0300 (-03) Received: from localhost (localhost [127.0.0.1]) by mail.datacom.com.br (Postfix) with ESMTP id 084111BA0F05; Sun, 7 Oct 2018 08:46:24 -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 PqQkSzsdM66R; Sun, 7 Oct 2018 08:46:23 -0300 (-03) Received: from p7-1130br.casantos.org (unknown [191.32.32.249]) by mail.datacom.com.br (Postfix) with ESMTPSA id 787031BA0F26; Sun, 7 Oct 2018 08:46:23 -0300 (-03) From: Carlos Santos To: buildroot@buildroot.org Date: Sun, 7 Oct 2018 08:46:00 -0300 Message-Id: <20181007114605.18153-4-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 3/8] rsyslog: 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 rsyslog startup script for better quality and code style: - Indent with tabs, not spaces. - 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 Tested-by: Matt Weber --- Changes v1->v2 - Implement suggestions made by Nicolas Cavallari and Arnout Vandecappelle Changes v2->v3 - Include /etc/default/logging, not /etc/default/$DAEMON. --- package/rsyslog/S01logging | 68 +++++++++++++++++++++++++------------- 1 file changed, 45 insertions(+), 23 deletions(-) diff --git a/package/rsyslog/S01logging b/package/rsyslog/S01logging index 8e4a59c2d5..5764780467 100644 --- a/package/rsyslog/S01logging +++ b/package/rsyslog/S01logging @@ -1,36 +1,58 @@ #!/bin/sh +DAEMON="rsyslogd" +PIDFILE="/var/run/$DAEMON.pid" + +RSYSLOGD_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 rsyslog daemon: " - start-stop-daemon -S -q -p /var/run/rsyslogd.pid --exec /usr/sbin/rsyslogd - [ $? = 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/rsyslogd -- $RSYSLOGD_ARGS + status=$? + if [ "$status" -eq 0 ]; then + echo "OK" + else + echo "FAIL" + fi + return "$status" } stop() { - printf "Stopping rsyslog daemon: " - start-stop-daemon -K -q -p /var/run/rsyslogd.pid - [ $? = 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() { - stop - sleep 1 - start + stop + sleep 1 + start } case "$1" in - start) - start - ;; - stop) - stop - ;; - restart|reload) - restart - ;; - *) - echo "Usage: $0 {start|stop|restart}" - exit 1 + start|stop|restart) + "$1";; + reload) + # Restart, since there is no true "reload" feature (does not + # reconfigure/restart on SIGHUP, just closes all open files). + restart;; + *) + echo "Usage: $0 {start|stop|restart|reload}" + exit 1 esac - -exit $? From patchwork Sun Oct 7 11:46:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Santos X-Patchwork-Id: 980124 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.138; helo=whitealder.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 whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42ShXg5BrJzB4MN for ; Sun, 7 Oct 2018 22:46:27 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 07788868B9; Sun, 7 Oct 2018 11:46:25 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 60iijhjiASZy; Sun, 7 Oct 2018 11:46:24 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id 05581866F0; Sun, 7 Oct 2018 11:46:24 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 5CF951BF42B for ; Sun, 7 Oct 2018 11:46:20 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 58EAF86866 for ; Sun, 7 Oct 2018 11:46:20 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wS+c6--v2ggx for ; Sun, 7 Oct 2018 11:46:18 +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 whitealder.osuosl.org (Postfix) with ESMTPS id 15C60864CB for ; Sun, 7 Oct 2018 11:46:17 +0000 (UTC) Received: from mail.datacom.com.br (localhost [127.0.0.1]) by mail.datacom.com.br (Postfix) with ESMTPS id AFA081BA0ED1; Sun, 7 Oct 2018 08:46:24 -0300 (-03) Received: from localhost (localhost [127.0.0.1]) by mail.datacom.com.br (Postfix) with ESMTP id 95DB21BA0F05; Sun, 7 Oct 2018 08:46:24 -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 AqRI_lM-LKzo; Sun, 7 Oct 2018 08:46:24 -0300 (-03) Received: from p7-1130br.casantos.org (unknown [191.32.32.249]) by mail.datacom.com.br (Postfix) with ESMTPSA id 0DE441BA0F30; Sun, 7 Oct 2018 08:46:24 -0300 (-03) From: Carlos Santos To: buildroot@buildroot.org Date: Sun, 7 Oct 2018 08:46:01 -0300 Message-Id: <20181007114605.18153-5-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 4/8] rsyslog: add logging configuration file 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" Provide a template to help users to customize rsyslog without editting the startup script. Also warn about options that must not be used. Add instructions on how to configure debugging, since it a bit tricky when rsyslogd runs in background, requiring a separete log file. This file is also useful as an example for init script authors. Signed-off-by: Carlos Santos Tested-by: Matt Weber --- Changes v1->v2 - Document that "-n" command line option must not be used. - Small improvements in comments. Changes v2->v3 - Add reference to documentation, as suggested by Matt Weber. --- package/rsyslog/etc.default.logging | 24 ++++++++++++++++++++++++ package/rsyslog/rsyslog.mk | 2 ++ 2 files changed, 26 insertions(+) create mode 100644 package/rsyslog/etc.default.logging diff --git a/package/rsyslog/etc.default.logging b/package/rsyslog/etc.default.logging new file mode 100644 index 0000000000..12223eba21 --- /dev/null +++ b/package/rsyslog/etc.default.logging @@ -0,0 +1,24 @@ +# +# /etc/default/logging (rsyslog version) +# +# Online documentation of rsyslog is available at +# +# https://www.rsyslog.com/doc/ +# +# Command line options are mostly undocumented in recent rsyslog versions, so +# avoid using them. Only "-n" and "-d" are briefly described when rsyslogd is +# invoked with the "-h" option. Other options are described on old versions of +# the rsyslogd(8) manual page but they are certainly outdated. +# + +# Use RSYSLOGD_ARGS to pass additional arguments to rsyslogd. +# - Do NOT use "-i pid_file", "-n", nor "-v", since they will break the +# startup script. +# - Use "-d" to enable debug (see below). Warning: log files may be HUGE! +# RSYSLOGD_ARGS="" # (default value) + +# You will need this along with "-d". +# RSYSLOG_DEBUGLOG="/var/log/rsyslogd"; export RSYSLOG_DEBUGLOG + +# Uncomment the line below to disable this service +# ENABLED="no" diff --git a/package/rsyslog/rsyslog.mk b/package/rsyslog/rsyslog.mk index 61e08ba765..c80d0696e2 100644 --- a/package/rsyslog/rsyslog.mk +++ b/package/rsyslog/rsyslog.mk @@ -74,6 +74,8 @@ endif define RSYSLOG_INSTALL_INIT_SYSV $(INSTALL) -m 0755 -D package/rsyslog/S01logging \ $(TARGET_DIR)/etc/init.d/S01logging + $(INSTALL) -m 0644 -D package/rsyslog/etc.default.logging \ + $(TARGET_DIR)/etc/default/logging endef # The rsyslog.service is installed by rsyslog, but the link is not created From patchwork Sun Oct 7 11:46:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Santos X-Patchwork-Id: 980127 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.138; helo=whitealder.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 whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42ShXm0159zB2xn for ; Sun, 7 Oct 2018 22:46:31 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id B56AE8685D; Sun, 7 Oct 2018 11:46:27 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UgxqmeX+zGgU; Sun, 7 Oct 2018 11:46:26 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id 6D2FC868DC; Sun, 7 Oct 2018 11:46:26 +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 888851BF429 for ; Sun, 7 Oct 2018 11:46:21 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 85BB721561 for ; Sun, 7 Oct 2018 11:46:21 +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 1iTUg6-YrGut for ; Sun, 7 Oct 2018 11:46:18 +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 silver.osuosl.org (Postfix) with ESMTPS id 6E9E921578 for ; Sun, 7 Oct 2018 11:46:18 +0000 (UTC) Received: from mail.datacom.com.br (localhost [127.0.0.1]) by mail.datacom.com.br (Postfix) with ESMTPS id 4A0891BA0F26; Sun, 7 Oct 2018 08:46:25 -0300 (-03) Received: from localhost (localhost [127.0.0.1]) by mail.datacom.com.br (Postfix) with ESMTP id 2AECC1BA0F05; Sun, 7 Oct 2018 08:46:25 -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 IWUEBXfpGpiX; Sun, 7 Oct 2018 08:46:25 -0300 (-03) Received: from p7-1130br.casantos.org (unknown [191.32.32.249]) by mail.datacom.com.br (Postfix) with ESMTPSA id 9D0881BA0F31; Sun, 7 Oct 2018 08:46:24 -0300 (-03) From: Carlos Santos To: buildroot@buildroot.org Date: Sun, 7 Oct 2018 08:46:02 -0300 Message-Id: <20181007114605.18153-6-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 5/8] sysklogd: 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 syslogd/klogd startup script for better quality and code style: - Implement start, stop, restart and reload as functions, like in other S01logging scripts, using start-stop-daemon. - Indent with tabs, not spaces. - Detect and report start/stop errors (previous version ignored them and always reported OK). - 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. - Do not kill syslogd in "reload". Send a SIGHUP signal, instructing it to perform a re-initialization. Also do not kill klogd. Send a signal (default 0, which does nothing). Users can configure this signal in /etc/default/logging to either SIGUSR1 or SIGUSR2. Signed-off-by: Carlos Santos --- Changes v1->v2 - Implement suggestions made by Arnout Vandecappelle Changes v2->v3 - Include /etc/default/logging, not /etc/default/$DAEMON. --- package/sysklogd/S01logging | 90 ++++++++++++++++++++++++++++--------- 1 file changed, 70 insertions(+), 20 deletions(-) diff --git a/package/sysklogd/S01logging b/package/sysklogd/S01logging index 1cbfe869fa..9b6e879d8a 100644 --- a/package/sysklogd/S01logging +++ b/package/sysklogd/S01logging @@ -1,25 +1,75 @@ #!/bin/sh -case "$1" in - start) - printf "Starting logging: " - /sbin/syslogd -m 0 - /sbin/klogd +DAEMON="sysklogd" +SPIDFILE="/var/run/syslogd.pid" +KPIDFILE="/var/run/klogd.pid" + +SYSLOGD_ARGS="-m 0" +KLOGD_ARGS="" +KLOGD_RELOAD="0" +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 %s: ' "$DAEMON" + status=0 + # shellcheck disable=SC2086 # we need the word splitting + start-stop-daemon -S -q -p "$SPIDFILE" -x /sbin/syslogd -- $SYSLOGD_ARGS || status=$? + start-stop-daemon -S -q -p "$KPIDFILE" -x /sbin/klogd -- $KLOGD_ARGS || status=$? + if [ "$status" -eq 0 ]; then + echo "OK" + else + echo "FAIL" + fi + return "$status" +} + +stop() { + printf 'Stopping %s: ' "$DAEMON" + status=0 + start-stop-daemon -K -q -p "$SPIDFILE" || status=$? + start-stop-daemon -K -q -p "$KPIDFILE" || status=$? + if [ "$status" -eq 0 ]; then echo "OK" - ;; - stop) - printf "Stopping logging: " - [ -f /var/run/klogd.pid ] && kill `cat /var/run/klogd.pid` - [ -f /var/run/syslogd.pid ] && kill `cat /var/run/syslogd.pid` + else + echo "FAIL" + fi + return "$status" +} + +restart() { + stop + sleep 1 + start +} + +# SIGHUP makes syslogd reload its configuration +# SIGUSR1 makes klogd reload kernel module symbols +# SIGUSR2 makes klogd reload static kernel symbols and kernel module symbols +reload() { + printf 'Reloading %s: ' "$DAEMON" + status=0 + start-stop-daemon -K -s HUP -q -p "$SPIDFILE" || status=$? + start-stop-daemon -K -s "$KLOGD_RELOAD" -q -p "$KPIDFILE" || status=$? + if [ "$status" -eq 0 ]; then echo "OK" - ;; - restart|reload) - $0 stop - $0 start - ;; - *) - echo "Usage: $0 {start|stop|restart}" - exit 1 -esac + else + echo "FAIL" + fi + return "$status" +} -exit $? +case "$1" in + start|stop|restart|reload) + "$1";; + *) + echo "Usage: $0 {start|stop|restart|reload}" + exit 1 +esac From patchwork Sun Oct 7 11:46:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Santos X-Patchwork-Id: 980125 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.136; helo=silver.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 silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42ShXk3PTjzB2xn for ; Sun, 7 Oct 2018 22:46:30 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id B1E9D22629; Sun, 7 Oct 2018 11:46:28 +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 KHOFP7XhXgDM; Sun, 7 Oct 2018 11:46:27 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 898B021561; Sun, 7 Oct 2018 11:46:27 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id A95201BF429 for ; Sun, 7 Oct 2018 11:46:21 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id A5543864CB for ; Sun, 7 Oct 2018 11:46:21 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ghjyYIOgZQbU for ; Sun, 7 Oct 2018 11:46:19 +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 whitealder.osuosl.org (Postfix) with ESMTPS id C9E1D867BB for ; Sun, 7 Oct 2018 11:46:18 +0000 (UTC) Received: from mail.datacom.com.br (localhost [127.0.0.1]) by mail.datacom.com.br (Postfix) with ESMTPS id C17781BA0F35; Sun, 7 Oct 2018 08:46:25 -0300 (-03) Received: from localhost (localhost [127.0.0.1]) by mail.datacom.com.br (Postfix) with ESMTP id B16631BA0F05; Sun, 7 Oct 2018 08:46:25 -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 fQ9goGH1kjwt; Sun, 7 Oct 2018 08:46:25 -0300 (-03) Received: from p7-1130br.casantos.org (unknown [191.32.32.249]) by mail.datacom.com.br (Postfix) with ESMTPSA id 2FB8D1BA0F30; Sun, 7 Oct 2018 08:46:25 -0300 (-03) From: Carlos Santos To: buildroot@buildroot.org Date: Sun, 7 Oct 2018 08:46:03 -0300 Message-Id: <20181007114605.18153-7-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 6/8] sysklogd: add logging configuration file 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" Provide a template to help users to customize syslogd and klogd without editting the startup script. Also warn about options that must not be used. syslogd options worth to configure are mark interval (-m), remote log support (-r) and domain list (-s). Give example of how to configure klogd re-initialization signal. Signed-off-by: Carlos Santos --- Changes v1->v2: - Document that the "-n" command line option must not be used. - Going against the request from Arnout Vandecappelle, keep the klogd reload configuration. Add a comment explainig why it is still useful. BTW, I work on a project which requires dynamic installation of kernel modules. Changes v2->v3 - Add reference to documentation, as suggested by Matt Weber. --- package/sysklogd/etc.default.logging | 33 ++++++++++++++++++++++++++++ package/sysklogd/sysklogd.mk | 2 ++ 2 files changed, 35 insertions(+) create mode 100644 package/sysklogd/etc.default.logging diff --git a/package/sysklogd/etc.default.logging b/package/sysklogd/etc.default.logging new file mode 100644 index 0000000000..a655e7ad42 --- /dev/null +++ b/package/sysklogd/etc.default.logging @@ -0,0 +1,33 @@ +# +# /etc/default/logging (sysklogd version) +# +# Documentation is available in the klogd.8 and sysklogd.8 manual pages +# distributed along with the source code. +# + +# Use SYSLOGD_ARGS to pass additional arguments to syslogd. +# - Do NOT use "-n", "-v", since they will break the startup script. +# - Do NOT use "-d", since debugging does not work when running in background. +# SYSLOGD_ARGS="-m 0" # (default value) + +# Use KLOGD_ARGS to pass additional arguments to klogd. +# - Do NOT use "-n", "-o" nor "-v", since they will break the startup script. +# - Do NOT use "-d", since debugging does not work when running in background. +# KLOGD_ARGS="-m 0" # (default value) + +# KLOGD_RELOAD selects the "S01logging reload" behavior. +# - "USR1" will cause the kernel module symbols to be reloaded. +# - "USR2" will cause both the static kernel symbols and the kernel module +# symbols to be reloaded. +# - "0" will do nothing. +# - Do not use any other value here. Use kill(1) for fine-grained control of +# klogd, as documented in its manual page. +# +# Most users will never need to reload klogd in buildroot context because they +# are not going to dynamically install kernel modules. In the rare cases that +# this does happen, the user should be smart enough to send a SIGUSR1/2 but +# let's keep this configurable for documentation purposes. +# KLOGD_RELOAD="0" # (default value) + +# Uncomment the line below to disable this service +# ENABLED="no" diff --git a/package/sysklogd/sysklogd.mk b/package/sysklogd/sysklogd.mk index c4f064c10b..b7e67ffee3 100644 --- a/package/sysklogd/sysklogd.mk +++ b/package/sysklogd/sysklogd.mk @@ -25,6 +25,8 @@ endef define SYSKLOGD_INSTALL_INIT_SYSV $(INSTALL) -m 755 -D package/sysklogd/S01logging \ $(TARGET_DIR)/etc/init.d/S01logging + $(INSTALL) -m 0644 -D package/sysklogd/etc.default.logging \ + $(TARGET_DIR)/etc/default/logging endef define SYSKLOGD_INSTALL_INIT_SYSTEMD 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 $? From patchwork Sun Oct 7 11:46:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Santos X-Patchwork-Id: 980128 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.137; helo=fraxinus.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 fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42ShXm38Q3zB3sq for ; Sun, 7 Oct 2018 22:46:32 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 2C3488592A; Sun, 7 Oct 2018 11:46:27 +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 BBKS9ZBH_BJR; Sun, 7 Oct 2018 11:46:24 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id B402C85B80; Sun, 7 Oct 2018 11:46:24 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id BA5441BF429 for ; Sun, 7 Oct 2018 11:46:20 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id B5444864CB for ; Sun, 7 Oct 2018 11:46:20 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Kr1eSEECvjou 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 whitealder.osuosl.org (Postfix) with ESMTPS id 0766C8685D for ; Sun, 7 Oct 2018 11:46:20 +0000 (UTC) Received: from mail.datacom.com.br (localhost [127.0.0.1]) by mail.datacom.com.br (Postfix) with ESMTPS id D8A9E1BA0F34; 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 CAED21BA0F05; 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 l56sa27jxMRh; 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 49C401BA0F31; Sun, 7 Oct 2018 08:46:26 -0300 (-03) From: Carlos Santos To: buildroot@buildroot.org Date: Sun, 7 Oct 2018 08:46:05 -0300 Message-Id: <20181007114605.18153-9-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 8/8] syslog-ng: add logging configuration file 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" Provide a template to help users to customize syslog-ng without editting the startup script. Mostly warn about options that must not be used. This file is also useful as an example for init script authors. Signed-off-by: Carlos Santos --- Changes v1->v2 - Document that -F/--foreground must not be used Changes v2->v3: - Add reference to documentation, as suggested by Matt Weber. - Fix copy/paste error spotted by Chris Packham (s/rsyslog/syslog-ng/). --- package/syslog-ng/etc.default.logging | 21 +++++++++++++++++++++ package/syslog-ng/syslog-ng.mk | 2 ++ 2 files changed, 23 insertions(+) create mode 100644 package/syslog-ng/etc.default.logging diff --git a/package/syslog-ng/etc.default.logging b/package/syslog-ng/etc.default.logging new file mode 100644 index 0000000000..f0f4d52b02 --- /dev/null +++ b/package/syslog-ng/etc.default.logging @@ -0,0 +1,21 @@ +# +# /etc/default/logging (syslog-ng version) +# +# Documentation is available in the syslog-ng.8 and syslog-ng.conf.5 manual +# pages distributed along with the source code, in the doc/man subdirectory. +# +# Online documentation of syslog-ng is available at +# +# https://www.syslog-ng.com/technical-documents/ +# + +# Use SYSLOG_NG_ARGS to pass additional arguments to syslog-ng. +# - Do NOT use "-F/--foreground", "--help"/"-h", "--version"/"-V", "--stderr"/"-e", +# "--syntax-only"/"-s", or "--process-mode=", since +# they will break the startup script. +# - Do NOT use "--debug"/"-d", since debugging does not work when running in +# background. +# SYSLOG_NG_ARGS="" # (default value) + +# Uncomment the line below to disable this service +# ENABLED="no" diff --git a/package/syslog-ng/syslog-ng.mk b/package/syslog-ng/syslog-ng.mk index 793fea0972..a837dad841 100644 --- a/package/syslog-ng/syslog-ng.mk +++ b/package/syslog-ng/syslog-ng.mk @@ -95,6 +95,8 @@ endif define SYSLOG_NG_INSTALL_INIT_SYSV $(INSTALL) -m 0755 -D package/syslog-ng/S01logging \ $(TARGET_DIR)/etc/init.d/S01logging + $(INSTALL) -m 0644 -D package/syslog-ng/etc.default.logging \ + $(TARGET_DIR)/etc/default/logging endef # By default syslog-ng installs a number of sample configuration