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