git.lirion.de

Of git, get, and gud

aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Pfeiffer <coding _ lirion.de> 2020-08-20 08:13:53 +0200
committerHarald Pfeiffer <coding _ lirion.de> 2020-08-20 08:13:53 +0200
commit62657cca461803604a18ea549c920a073fd10691 (patch)
tree1f20592671bec7b31ff8d8d463a21afc81a185b6
parentbce94c9f77eebe4fc9bb0b58afe04f5c276532de (diff)
downloadrhel-scripts-62657cca461803604a18ea549c920a073fd10691.tar.bz2
Adding in count of updates
-rwxr-xr-xbin/dnfu11
1 files changed, 10 insertions, 1 deletions
diff --git a/bin/dnfu b/bin/dnfu
index 175be76..0c15bd2 100755
--- a/bin/dnfu
+++ b/bin/dnfu
@@ -172,7 +172,16 @@ if [ "$UPDAVAIL" -eq 0 ];then
supgrade
fi
#printf "Checking for outdated running services or necessity to reboot...:\n"
-sudo "${UCMD}" needs-restarting -C 2>/dev/null|grep -P '^[0-9]+[ ]+:'|wc -l
+UPDNUM="$(sudo "${UCMD}" needs-restarting -C 2>/dev/null|grep -Pc '^[0-9]+[ ]+:')"
+if echo "$UPDNUM"|grep -P '^[0-9]+$' >/dev/null;then
+ case "$UPDNUM" in
+ 0) printf "No service requires reboot.\n";;
+ 1) printf "1 service requires reboot.\n";sudo "${UCMD}" needs-restarting -C 2>/dev/null|tee -a "$DLOG";;
+ *) printf "%b services require reboot.\n" "$UPDNUM";sudo "${UCMD}" needs-restarting -C 2>/dev/null|tee -a "$DLOG";;
+ esac
+else
+ printf "Error while fetching number of services requiring reboot.\n" >&2
+fi
sudo "${UCMD}" needs-restarting -C -r --color true 2>&1|tee -a "$DLOG"
sudo "${UCMD}" needs-restarting -r >/dev/null 2>&1 ||$LWCMD "Reboot required."||: