From 62657cca461803604a18ea549c920a073fd10691 Mon Sep 17 00:00:00 2001
From: Harald Pfeiffer <coding@lirion.de>
Date: Thu, 20 Aug 2020 08:13:53 +0200
Subject: Adding in count of updates

---
 bin/dnfu | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

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."||:
 
-- 
cgit v1.2.3