patchman
patchman copied to clipboard
Detect if reboot is required on RHEL and CentOS >= 7
Hi,
do you think it would be possible to add this (or something like that) to patchman-client at reboot_required() to also detect if a reboot is required on RHEL and CentOS >= 7 ?
# On RHEL and CentOS >= 7 clients, the yum-utils or dnf
# package needs to be installed for this to work.
if check_command_exists needs-restarting ; then
if [[ $(needs-restarting -r >/dev/null) -eq 1 ]]; then
reboot=True
else
reboot=ServerCheck
fi
elif check_command_exists dnf ; then
if [[ $(dnf needs-restarting -r >/dev/null) -eq 1 ]]; then
reboot=True
else
reboot=ServerCheck
fi
fi
Looks good, please submit a PR and I'll test it.
@ocnbb
If you add ; echo $? to your command substitution, then it should work as expected.
=> $(needs-restarting -r >/dev/null ; echo $?) -eq 1
Otherwise it won't ouput the correct linux status code. I tested it and it is now working as expected.