diff options
author | mail_redacted_for_web | 2020-08-20 08:13:53 +0200 |
---|---|---|
committer | mail_redacted_for_web | 2020-08-20 08:13:53 +0200 |
commit | 62657cca461803604a18ea549c920a073fd10691 (patch) | |
tree | 1f20592671bec7b31ff8d8d463a21afc81a185b6 /bin/dnfu | |
parent | bce94c9f77eebe4fc9bb0b58afe04f5c276532de (diff) | |
download | rhel-scripts-62657cca461803604a18ea549c920a073fd10691.tar.bz2 |
Adding in count of updates
Diffstat (limited to 'bin/dnfu')
-rwxr-xr-x | bin/dnfu | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -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."||: |