gplv3/crontabs/centos/patches/run-parts-add-option-to-rem...

66 lines
1.9 KiB
Diff

From f0bd54cb83ba430ef81153c7a6da2a52daca5266 Mon Sep 17 00:00:00 2001
From: Michel Thebeau <michel.thebeau@windriver.com>
Date: Mon, 25 Jul 2016 11:23:18 -0400
Subject: [PATCH] run-parts: add option to remove printing of motd script name
The awk statement seems to be a round-about way of printing the name of
the motd script (/etc/motd.d/*). The pipe seems to allow awk to print
without user input; while the end of input causes awk to exit. Any
input to awk is echoed to terminal before the motd script name is
printed.
The script name that is printed is appended to /etc/motd. This is
undesirable. Add an option to skip the awk program.
Signed-off-by: Michel Thebeau <michel.thebeau@windriver.com>
---
run-parts | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/run-parts b/run-parts
index 7e148f8..b444f4e 100755
--- a/run-parts
+++ b/run-parts
@@ -4,6 +4,14 @@
# keep going when something fails
set +e
+# First parameter to remove printing of the names of executed scripts.
+# The default is unmodified behaviour, print the name of scripts.
+with_progname="y"
+if [ "$1" == "--without-progname" ]; then
+ with_progname=""
+ shift
+fi
+
if [ $# -lt 1 ]; then
echo "Usage: run-parts [--list | --test] <dir>"
exit 1
@@ -87,12 +95,17 @@ for i in $(LC_ALL=C; echo ${1%/}/*[^~,]) ; do
# run executable files
logger -p cron.notice -t "run-parts($1)[$$]" "starting $(basename $i)"
- $i 2>&1 | awk -v "progname=$i" \
- 'progname {
- print progname ":\n"
- progname="";
- }
- { print; }'
+ if [ -n "$with_progname" ]; then
+ $i 2>&1 | awk -v "progname=$i" \
+ 'progname {
+ print progname ":\n"
+ progname="";
+ }
+ { print; }'
+ else
+ $i 2>&1
+ fi
+
logger -i -p cron.notice -t "run-parts($1)" "finished $(basename $i)"
fi
fi
--
1.8.3.1