Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect if reboot is required on RHEL and CentOS >= 7 #317

Open
ocnbb opened this issue Apr 16, 2021 · 2 comments
Open

Detect if reboot is required on RHEL and CentOS >= 7 #317

ocnbb opened this issue Apr 16, 2021 · 2 comments

Comments

@ocnbb
Copy link

ocnbb commented Apr 16, 2021

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
@furlongm
Copy link
Owner

Looks good, please submit a PR and I'll test it.

@prismisch
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants