Arturo Borrero Gonzalez has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/398458 )

Change subject: apt: report-pending-upgrades.sh: add verbosity flag
......................................................................

apt: report-pending-upgrades.sh: add verbosity flag

Add a new verbosity flag to control how many output we get.
This is useful to avoid information flood when running with clush.

By default the script will only output the summary, unless call
with '-v'.

Bug: T181647
Change-Id: I2d4766f04337774e021904441e09cba86500d769
Signed-off-by: Arturo Borrero Gonzalez <aborr...@wikimedia.org>
---
M modules/apt/files/report-pending-upgrades.sh
1 file changed, 10 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/58/398458/1

diff --git a/modules/apt/files/report-pending-upgrades.sh 
b/modules/apt/files/report-pending-upgrades.sh
index 32a53ac..814b819 100644
--- a/modules/apt/files/report-pending-upgrades.sh
+++ b/modules/apt/files/report-pending-upgrades.sh
@@ -21,6 +21,10 @@
 UNATTENDED_UPGRADES=$(get_binary unattended-upgrades)
 set +e
 
+if [ "$1" == "-v" ] ; then
+       VERBOSE=y
+fi
+
 $APT_GET update >/dev/null
 
 # get upgradeable packages
@@ -33,16 +37,18 @@
     src_output=$(echo "$APT_SHOW_VERSIONS_OUTPUT" | grep "/$src ")
     n3=$(echo "$src_output" | wc -l)
     echo "I: upgradeable packages from ${src}: $n3"
-    echo
-    echo "$src_output" | sed -e 's/^/  /' # add spaces to output
-    echo
+    if [ "$VERBOSE" == "y" ] ; then
+        echo
+        echo "$src_output" | sed -e 's/^/  /' # add spaces to output
+        echo
+    fi
   done
 fi
 
 # get upgradeable packages by current unattended-upgrades config
 UNATTENDED_UPGRADES_OUTPUT=$($UNATTENDED_UPGRADES --dry-run -v -d | grep 
"Packages that will be upgraded" | awk -F':' '{print $2}' | grep -v 
^[[:space:]]*$)
 n2=$(echo "$UNATTENDED_UPGARDES_OUTPUT" | grep -v ^$ | wc -l)
-if [ "$n2" != "0" ] ; then
+if [ "$n2" != "0" ] && [ "$VERBOSE" == "y" ] ; then
   echo "I: upgradeable packages by unattended-upgrades: $n2"
   echo
   echo "$UNATTENDED_UPGARDES_OUTPUT" | sed -e 's/^/  /' # add spaces to output

-- 
To view, visit https://gerrit.wikimedia.org/r/398458
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2d4766f04337774e021904441e09cba86500d769
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Arturo Borrero Gonzalez <aborr...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to