Check if a reboot is neccessary

It seems to be a hook.

No, it’s some libalpm magic actually
Which is beyond my knowledge :upside_down_face:

I just have overviewed all libalpm hooks and scripts. I can confirm ist is “some magic”. Not to see immediately… And I agree it must be a hook.

EDIT:
Anyway: I take this you all have worked out as a solution. Many thanks for your help!

1 Like

I see I can give only one post the attribute “solution”. In this case I would give it to more contributors :wink:

Glad that I have choosen Endeavour as my Arch-based distro (coming from Antergos) and that the community is more alive than ever and to be a part of it!

Stay healthy

4 Likes

and hydrated! :frog:

:beers:

2 Likes

Amen! :rocket:
Love the sound of bouncing ideas! :partying_face:

P.S.

I was about to write: “HOW DARE YOU?!?!?” :rofl:
awk is cool! :slight_smile: :frog:

1 Like

that`s a hook…

1 Like

Generally if it’s not the kernel, systemd or graphics relates a reboot is needed. For services, they can be restarted without a reboot. I generally just look at the list of packages being upgraded and make a decision if I have to reboot, restart a service or my session. If in doubt I reboot.

I only update every week or two depending on my work schedule. I haven’t seemed to have any issues with it so far. I always reboot after.

Here’s a script that looks for reboot-requiring packages from /etc/pacman.d/hooks/eos-reboot-required.hook.
Otherwise it is quite similar to what @Kresimir showed.

#!/bin/bash

# Check if a reboot would be necessary after system update.

DIE() {
    echo "Error: $1" >&2
    exit 1
}

Main()
{
    local updates
    local hookpkgs
    local up hook

    pacman -Q eos-update-notifier >&/dev/null || DIE "sorry, package eos-update-notifier is required."

    readarray -t updates  <<< $(checkupdates | awk '{print $1}')
    readarray -t hookpkgs <<< $(cat /etc/pacman.d/hooks/eos-reboot-required.hook | grep "^Target = " | awk '{print $3}')

    for up in "${updates[@]}" ; do
        for hook in "${hookpkgs[@]}" ; do
            case "$up" in
                $hook)
                    echo "Reboot will be required after system update." >&2
                    return 0
                    ;;
            esac
        done
    done
    echo "Reboot will not be required after updating." >&2
    return 1
}

Main "$@"
4 Likes