git.lirion.de

Of git, get, and gud

aboutsummaryrefslogtreecommitdiffstats
path: root/bin/dnfu
diff options
context:
space:
mode:
Diffstat (limited to 'bin/dnfu')
-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."||: