From patchwork Sun Mar 29 23:49:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Santos X-Patchwork-Id: 1263576 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.138; helo=whitealder.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.a=rsa-sha256 header.s=20161025 header.b=DUFz3byh; dkim-atps=neutral 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 48rC4Q6mgRz9sQt for ; Mon, 30 Mar 2020 10:49:42 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 959D0874E9; Sun, 29 Mar 2020 23:49:40 +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 PYvrBGZSqoq6; Sun, 29 Mar 2020 23:49:39 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id 700938756D; Sun, 29 Mar 2020 23:49:39 +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 7B5D11BF475 for ; Sun, 29 Mar 2020 23:49:37 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 7473A2052C for ; Sun, 29 Mar 2020 23:49:37 +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 3fi6FzDO4eVf for ; Sun, 29 Mar 2020 23:49:35 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-qt1-f181.google.com (mail-qt1-f181.google.com [209.85.160.181]) by silver.osuosl.org (Postfix) with ESMTPS id 5C4382043A for ; Sun, 29 Mar 2020 23:49:35 +0000 (UTC) Received: by mail-qt1-f181.google.com with SMTP id c9so13706435qtw.7 for ; Sun, 29 Mar 2020 16:49:35 -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:in-reply-to:references; bh=7hNWG4w7zbfrjSleW90b0XK818wcAyyLHCUZ3Eowr+Y=; b=DUFz3byhnIlemq4mtmeHLp7EgyM9d1n9jIDUjywWBMXXI6dxWsYopNnZW3sbHQYOsl dmHDw58rKAHjK4n5+7JT8JcujqVIQhkKgVy51Qg3QTOBOkHh39BM5prgoysbJk8byg20 ag1McA7ACiiMYgXQL4z/uOtWoj/kW5eyhGwAUAMCve7Fmt2CZVnF2T7fj37IBHnG8Vhm jjOMC9zSAV6ClCRcpARC4frNTYZpQoiDM/4brwtsA7ul7gjdXC5vPNaBlyVYCOdrdhuR 5Iv5tSqW/0qCldQNfXcMUmEQz9A712WDHRR5W+HbzBBGyWq74NE3K4e0DtwDbd9rzsMN Bg+A== 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:in-reply-to :references; bh=7hNWG4w7zbfrjSleW90b0XK818wcAyyLHCUZ3Eowr+Y=; b=cRDSumHgCNe+qPOJ9K1vMvQVPCpvOmDMA3o48S9eFXgPlH8KeibXCBLWWnvjV0bYsp Edc0gPTz3aW4zg1hl9iQ6UdZ5PKCAWvqvp+O7ZSIMpqpDaZY1GNF4VIQ8M2ccdLlaBHG OW3kNf7vZcIsrpqHgD2j+r9cIIkA6hnDb7umhWzbUUFUbPbpG6v76AMns5T2IHxXpvcf wIi+2oweI/28q+G/wnBzIvQSKpZc2MI4sHJ9oDTKl5P0BK2YMOnSlUX1Tew1K8PIIRaJ uhN9H/lAK73Qjakx7QwKe+YZ6glH3M24IOtB6LyimkNimd4CTWHU1sgJSLaaJe7f75el fpsA== X-Gm-Message-State: ANhLgQ3F/5c+Pmhq+1jBvqrETVKn8mHA5cWg/mu6+kUi5eEtUdvl9m+V RjcqsIP05yrUlmLe/CKR+UNiPQ3w X-Google-Smtp-Source: ADFU+vtEOhLAEJjVU4GSl64qvAQjOkLye81Czc6SUAANy58f8sU5YntS4dECkIiY3fYt/0PYLjormg== X-Received: by 2002:ac8:342b:: with SMTP id u40mr9069452qtb.83.1585525774095; Sun, 29 Mar 2020 16:49:34 -0700 (PDT) Received: from casantos.remote.csb.com (201.22.223.113.dynamic.adsl.gvt.net.br. [201.22.223.113]) by smtp.gmail.com with ESMTPSA id l7sm8843689qkb.47.2020.03.29.16.49.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Mar 2020 16:49:33 -0700 (PDT) From: unixmania@gmail.com To: buildroot@buildroot.org Date: Sun, 29 Mar 2020 20:49:22 -0300 Message-Id: <20200329234924.14505-2-unixmania@gmail.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20200329234924.14505-1-unixmania@gmail.com> References: <20200329234924.14505-1-unixmania@gmail.com> Subject: [Buildroot] [PATCH 1/3] pakage/busybox: use same S02sysctl script as procps-ng 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 , Adam Duskett MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" From: Carlos Santos The scripts were already the same, except for some comments, so make the busybox S02sysctl a symlink to the procps-ng one, which works with both versions of the "sysctl" utility. Signed-off-by: Carlos Santos --- package/busybox/S02sysctl | 67 +-------------------------------------- 1 file changed, 1 insertion(+), 66 deletions(-) mode change 100644 => 120000 package/busybox/S02sysctl diff --git a/package/busybox/S02sysctl b/package/busybox/S02sysctl deleted file mode 100644 index 6bb2fa165e..0000000000 --- a/package/busybox/S02sysctl +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/sh - -PROGRAM="sysctl" - -SYSCTL_ARGS="" - -# shellcheck source=/dev/null -[ -r "/etc/default/$PROGRAM" ] && . "/etc/default/$PROGRAM" - -# Files are read from directories in the SYSCTL_SOURCES list, in the given -# order. A file may be used more than once, since there can be multiple -# symlinks to it. No attempt is made to prevent this. -SYSCTL_SOURCES="/etc/sysctl.d/ /usr/local/lib/sysctl.d/ /usr/lib/sysctl.d/ /lib/sysctl.d/ /etc/sysctl.conf" - -# Use some scripting to mimic the --system option of the sysctl provided by -# procps-ng but still reporting errors. Users not interested on error report -# can put "-e" in SYSCTL_ARGS. -# -# The file redirections do the following: -# -# - stdout is redirected to syslog with facility.level "kern.info" -# - stderr is redirected to syslog with facility.level "kern.err" -# - file dscriptor 4 is used to pass the result to the "start" function. -# -# Testing the sysctl exit code is fruitless, as at the moment, since it ends -# with status zero even if errors happen. Hopefully this will be fixed in a -# future version of Busybox. -# -run_program() { - # shellcheck disable=SC2086 # we need the word splitting - find $SYSCTL_SOURCES -maxdepth 1 -name '*.conf' -print0 2> /dev/null | \ - xargs -0 -r -n 1 readlink -f | { - prog_status="OK" - while :; do - read -r file - if [ -z "$file" ]; then - echo "$prog_status" >&4 - break - fi - echo "* Applying $file ..." - /sbin/sysctl -p "$file" $SYSCTL_ARGS || prog_status="FAIL" - done 2>&1 >&3 | /usr/bin/logger -t sysctl -p kern.err - } 3>&1 | /usr/bin/logger -t sysctl -p kern.info -} - -start() { - printf '%s %s: ' "$1" "$PROGRAM" - status=$(run_program 4>&1) - echo "$status" - if [ "$status" = "OK" ]; then - return 0 - fi - return 1 -} - -case "$1" in - start) - start "Running";; - restart|reload) - start "Rerunning";; - stop) - :;; - *) - echo "Usage: $0 {start|stop|restart|reload}" - exit 1 -esac diff --git a/package/busybox/S02sysctl b/package/busybox/S02sysctl new file mode 120000 index 0000000000..796855c332 --- /dev/null +++ b/package/busybox/S02sysctl @@ -0,0 +1 @@ +../procps-ng/S02sysctl \ No newline at end of file From patchwork Sun Mar 29 23:49:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Santos X-Patchwork-Id: 1263577 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.a=rsa-sha256 header.s=20161025 header.b=RJqVrQs3; 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 48rC4S18tFz9sR4 for ; Mon, 30 Mar 2020 10:49:44 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 6489A87EBB; Sun, 29 Mar 2020 23:49:42 +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 pg2meSIjAth7; Sun, 29 Mar 2020 23:49:40 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id 634B887E6F; Sun, 29 Mar 2020 23:49:40 +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 997691BF475 for ; Sun, 29 Mar 2020 23:49:38 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 9669386FD1 for ; Sun, 29 Mar 2020 23:49:38 +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 3gw9QuoRSLl3 for ; Sun, 29 Mar 2020 23:49:37 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-qt1-f196.google.com (mail-qt1-f196.google.com [209.85.160.196]) by whitealder.osuosl.org (Postfix) with ESMTPS id 5AF7686EAC for ; Sun, 29 Mar 2020 23:49:37 +0000 (UTC) Received: by mail-qt1-f196.google.com with SMTP id t17so13672519qtn.12 for ; Sun, 29 Mar 2020 16:49:37 -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:in-reply-to:references; bh=ijbaoLsmlnU1ajnkVWC66P5mmyVc4imWc2fbclDqoJI=; b=RJqVrQs34pA4rJAlNRIv6HitTwNm3g3BsLwW8HBQIcvVwST8Jew81WYFaTza3Z1W/b 6uxhxJa+cD5d0QQfZn9+tWGa1a/4rTufcbFTfrhp5mLx1gyStUuJQNYvjTpuYyS3+AI5 kpfOuHs8iNlHD77zNcAO0d6cCPKEWfUgaWnUCNujUyJUDtMsTYVqY0PNcTdmkHrU/JLp a279NrvbumQYHJxjbhYj0NG91skP8DJ5qnkZm3Bsi/eNx5dJSyuPS3MHq17CkMb/94W0 P8CINMzAGZ2ceyU7RDY8TP5Uo1cFwnf3PFiiFyuPAF+PMhC+sCX00YJUpDpeEhnzI3k/ Y7oA== 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:in-reply-to :references; bh=ijbaoLsmlnU1ajnkVWC66P5mmyVc4imWc2fbclDqoJI=; b=qefvMpy06XZdLrzgsQSfDmdLKm39tmfFVfPHueD8F4Hl7bXP8B9Q+oWRac7rX1eQHN 1ZneH//+aIwUMa88D4O0W6EqhlYrW4q3sr5gDT4VxzKqf2ni1YLskqk0keEA4+/AF9mc 8cf8x4d9pYw/cRnqH6RRg7YTsHj8VV9p58DVy2uDBp0adtBbe18bQ1KbRa218xDZzNAh LvnOnltrGCSxekjN8PJm9EoaBPZWgJWkZ4545+WdKHJ9q2KUmKj3THR3L3146AYwOFhz t/6pvZTHIcLZDe0X4DSAvX0Dju522JxUnaXErNa1H59I5JZts+h0OnmH3hYQ1UilQ9f1 KMng== X-Gm-Message-State: ANhLgQ1B4fD5Tfhix7m7QNME5C2Ud8W4Z5IoEKdZw9F7TskVBQ+8c7Vg ATQms10euArbUk4HBWZe+5MC1pOm X-Google-Smtp-Source: ADFU+vvqZqSsfaUmAQuChvU/coumWYwLyPdhfYlYUsJQV6WNepAbuQdsqc+IYlsSN5aYTheYn+UzBg== X-Received: by 2002:aed:3383:: with SMTP id v3mr9595168qtd.177.1585525776075; Sun, 29 Mar 2020 16:49:36 -0700 (PDT) Received: from casantos.remote.csb.com (201.22.223.113.dynamic.adsl.gvt.net.br. [201.22.223.113]) by smtp.gmail.com with ESMTPSA id l7sm8843689qkb.47.2020.03.29.16.49.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Mar 2020 16:49:35 -0700 (PDT) From: unixmania@gmail.com To: buildroot@buildroot.org Date: Sun, 29 Mar 2020 20:49:23 -0300 Message-Id: <20200329234924.14505-3-unixmania@gmail.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20200329234924.14505-1-unixmania@gmail.com> References: <20200329234924.14505-1-unixmania@gmail.com> Subject: [Buildroot] [PATCH 2/3] package/procps-ng: add busybox-related comments to S02sysctl 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 , Adam Duskett MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" From: Carlos Santos Explain the busybox peculiarities and how the script works with both versions of the sysctl utility. Signed-off-by: Carlos Santos --- package/procps-ng/S02sysctl | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/package/procps-ng/S02sysctl b/package/procps-ng/S02sysctl index 3a58578de4..fed64e91a6 100644 --- a/package/procps-ng/S02sysctl +++ b/package/procps-ng/S02sysctl @@ -1,4 +1,17 @@ #!/bin/sh +# +# This script is used by busybox and procps-ng. +# +# With procps-ng, the "--system" option of sysctl also enables "--ignore", so +# errors are not reported via syslog. Use the run_logger function to mimic the +# --system behavior, still reporting errors via syslog. Users not interested +# on error reports can add "-e" to SYSCTL_ARGS. +# +# busybox does not have a "--system" option neither reports errors via syslog, +# so the scripting provides a consistent behavior between the implementations. +# Testing the busybox sysctl exit code is fruitless, as at the moment, since +# its exit status is zero even if errors happen. Hopefully this will be fixed +# in a future busybox version. PROGRAM="sysctl" @@ -12,12 +25,6 @@ SYSCTL_ARGS="" # symlinks to it. No attempt is made to prevent this. SYSCTL_SOURCES="/etc/sysctl.d/ /usr/local/lib/sysctl.d/ /usr/lib/sysctl.d/ /lib/sysctl.d/ /etc/sysctl.conf" -# The "--system" option activates "--ignore", which is bad because invalid -# variable settings in the configuration files will not be reported on the -# system log. Use some scripting to mimic the --system behavior but still -# reporting errors. Users not interested on error report can put "-e" in -# SYSCTL_ARGS. -# # The file redirections do the following: # # - stdout is redirected to syslog with facility.level "kern.info" From patchwork Sun Mar 29 23:49:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Santos X-Patchwork-Id: 1263578 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.136; helo=silver.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.a=rsa-sha256 header.s=20161025 header.b=c7Rqeihk; dkim-atps=neutral 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 48rC4T6Cx6z9sQt for ; Mon, 30 Mar 2020 10:49:45 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id ABEE221515; Sun, 29 Mar 2020 23:49:43 +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 qnS4U5mmRcbp; Sun, 29 Mar 2020 23:49:42 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 846A62052C; Sun, 29 Mar 2020 23:49:42 +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 2D94D1BF909 for ; Sun, 29 Mar 2020 23:49:40 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 2844F2052C for ; Sun, 29 Mar 2020 23:49:40 +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 C75fvuFKPCio for ; Sun, 29 Mar 2020 23:49:39 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-qk1-f179.google.com (mail-qk1-f179.google.com [209.85.222.179]) by silver.osuosl.org (Postfix) with ESMTPS id 6556E2043A for ; Sun, 29 Mar 2020 23:49:39 +0000 (UTC) Received: by mail-qk1-f179.google.com with SMTP id v7so17309036qkc.0 for ; Sun, 29 Mar 2020 16:49:39 -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:in-reply-to:references; bh=zHJHKaGIbUZOuIJWpAZp8z0I4eXJykGvT59M4Fp+4Og=; b=c7Rqeihk1JtiJsz3DM0JTf8qhxFPMJjh174ndoQY0ZwXSjPfAqXc75lC2h+fUmNOpu IUqCiRoOEs34r6VL0lbT9RLDL6CYSSaGlVilQWuhZSsKnUOdg0eemk1zbfxcAUD7VleI RyI1nw6uCZvxpGrD9xmvWaWefsNfGIUm74YkFxnnCghoEwpD31XGHR6QaTf1OCBrLJOe pNLTQJpahGVfjuiy6cagUSJDMDEtsu/ZZx14Ig4BDx3dVoHGYCgxwuJtYvdNP6tjC7uU Gagvh538NVh1BPwXgdWaTvIA7jK1VLoU6pzWKWlcOB68owBRylzr3/83jTqemStGY1Yn ZVkA== 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:in-reply-to :references; bh=zHJHKaGIbUZOuIJWpAZp8z0I4eXJykGvT59M4Fp+4Og=; b=CoHzYD1GHYzfgRrdrOvS6EYm/ycGVN7KfSYfD+bPV739Dj46CanBzhIvU8rXOTe6X3 5XauhFn+sqJ0tYtTXBQuGFPdBylcECd5q0beacZq/f7reqPTjvBNVnmewKSeZ9M00TPG CPr6dGb1jbNwWZ/9OQMet76puAX2uwxB0L126Hnbi/52V1GUNtewhoOZqsNDcsfAL7G+ dqefvYPNhuXMHggNwEWp9Fb4vB11yaWKxb1tkOGU00m5BJjWNUzRDH0DNX3CfEdFHwSW wRxcsbD86H1WXMmtdvfKG0yf1CZKOwjwb2VeKv2coKewUTIqafOj+6L60mm8Krn5gwt4 j/CQ== X-Gm-Message-State: ANhLgQ2LVFJGWNJJ9jnF5julRZ6QQYTpAd3MPSdseu9cGmFd9CYREvM5 AlQoB80Rp2Wb+KE7F7R1Vms3djii X-Google-Smtp-Source: ADFU+vuBO4b2yLOohwquT80J36OVQC8OE/2VJf0G3n8ewRqLpdesl2e01wYgIlsLSQ40htsa0ifT/A== X-Received: by 2002:a37:5004:: with SMTP id e4mr9574705qkb.18.1585525778102; Sun, 29 Mar 2020 16:49:38 -0700 (PDT) Received: from casantos.remote.csb.com (201.22.223.113.dynamic.adsl.gvt.net.br. [201.22.223.113]) by smtp.gmail.com with ESMTPSA id l7sm8843689qkb.47.2020.03.29.16.49.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Mar 2020 16:49:37 -0700 (PDT) From: unixmania@gmail.com To: buildroot@buildroot.org Date: Sun, 29 Mar 2020 20:49:24 -0300 Message-Id: <20200329234924.14505-4-unixmania@gmail.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20200329234924.14505-1-unixmania@gmail.com> References: <20200329234924.14505-1-unixmania@gmail.com> Subject: [Buildroot] [PATCH 3/3] pakage/procps-ng: use logger in S02sysctl only if it is available 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 , Adam Duskett MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" From: Carlos Santos The script used the logger utility unconditionally but it may not exist (e.g. busybox-minimal.config is used and BR2_PACKAGE_UTIL_LINUX_LOGGER is not selected). Declare two functions to perform the operation, run_logger and run_std, and use the appropriate one, depending on the existence of logger. Signed-off-by: Carlos Santos --- package/procps-ng/S02sysctl | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/package/procps-ng/S02sysctl b/package/procps-ng/S02sysctl index fed64e91a6..85d9ed50d0 100644 --- a/package/procps-ng/S02sysctl +++ b/package/procps-ng/S02sysctl @@ -25,32 +25,55 @@ SYSCTL_ARGS="" # symlinks to it. No attempt is made to prevent this. SYSCTL_SOURCES="/etc/sysctl.d/ /usr/local/lib/sysctl.d/ /usr/lib/sysctl.d/ /lib/sysctl.d/ /etc/sysctl.conf" -# The file redirections do the following: +# If the logger utility is available all messages are sent to syslog, except +# for the final status. The file redirections do the following: # # - stdout is redirected to syslog with facility.level "kern.info" # - stderr is redirected to syslog with facility.level "kern.err" # - file dscriptor 4 is used to pass the result to the "start" function. # -run_program() { +run_logger() { # shellcheck disable=SC2086 # we need the word splitting find $SYSCTL_SOURCES -maxdepth 1 -name '*.conf' -print0 2> /dev/null | \ xargs -0 -r -n 1 readlink -f | { prog_status="OK" while :; do - read -r file - if [ -z "$file" ]; then + read -r file || { echo "$prog_status" >&4 break - fi + } echo "* Applying $file ..." /sbin/sysctl -p "$file" $SYSCTL_ARGS || prog_status="FAIL" done 2>&1 >&3 | /usr/bin/logger -t sysctl -p kern.err } 3>&1 | /usr/bin/logger -t sysctl -p kern.info } +# If logger is not available all messages are sent to stdout/stderr. +run_std() { + # shellcheck disable=SC2086 # we need the word splitting + find $SYSCTL_SOURCES -maxdepth 1 -name '*.conf' -print0 2> /dev/null | \ + xargs -0 -r -n 1 readlink -f | { + prog_status="OK" + while :; do + read -r file || { + echo "$prog_status" >&4 + break + } + echo "* Applying $file ..." + /sbin/sysctl -p "$file" $SYSCTL_ARGS || prog_status="FAIL" + done + } +} + +if [ -x /usr/bin/logger ]; then + run_program="run_logger" +else + run_program="run_std" +fi + start() { printf '%s %s: ' "$1" "$PROGRAM" - status=$(run_program 4>&1) + status=$("$run_program" 4>&1) echo "$status" if [ "$status" = "OK" ]; then return 0