Check if a reboot is neccessary

Not best for Arch server, there may be some small security updates which doesn’t require update but important for security to get fast

But it is not determinable… :sleepy: :zipper_mouth_face: :unamused: That is the reason I want to get this information BEFORE an upgrade run. 90% of upgrades do not need a reboot.

@keybreak
I was very proud that security upgrades reach Arch days, sometimes weeks, before they hit Debian… I do not want to throw away this adavantage - so you are absolutely right.

Then the interval between your updates should be less than this, in order to have this “advantage”.

The truth is: rolling releases are not the best solution for a production server. There is a reason most servers run on Debian or Ubuntu.

This forum, if I’m not mistaken, runs on ngix on Ubuntu :wink:

3 Likes

Until someone more experienced will come, you can try to check those utilities in VM or inspect their source, maybe they got something like that:
https://wiki.archlinux.org/index.php/Pacman/Tips_and_tricks#Utilities

2 Likes

@Kresimir
Of course most servers run Debian based distros. Most PCs run Windows. The first one does not prevent me from using a “better” Distro and the last one does not prevent me from using Linux :grin:

I am nearly sure that can be solved - like everything that I have solved migrating a huge server installation from Debian to Arch…

3 Likes

Or update another computer that has all the packages that the server has, paying attention to which updates require a reboot, if any (for example, your home desktop, running Arch <- this is an arbitrary example, please don’t reply that you don’t have a home desktop running Arch).

1 Like

I know dozens of workarounds - more or less complicated. Now I have the time to think about a better solution - and I have time to wait for someone with much more experience. I am not a beginner at all - but here my ideas are not helpful. The only idea I have is digging into pacman source and look what happens. That is not easy at all.

https://github.com/endeavouros-team/PKGBUILDS/tree/master/eos-update-notifier

using notify-send but could be changed to notify you in terminal somehow?

5 Likes

I mean, just reboot when it’s convenient :slight_smile: I’ve done kernel updates and not rebooted for a LONG time afterwards with no ill effect and I’ve been doing this for years. If you got a slow machine, do upgrades once a week and reboot then. Pretty simple and saves you having to screw around otherwise.

2 Likes

@joekamprad
That looks nice. I am not sure pacman uses same algo because sometimes after an systemd upgrade it does not tell me reboot is needed and sometimes it does. But it is a much better approach than anyone I have before!

@alenbasic
Concrete example: there is more than network card and a special usb device present at the server. After a kernel upgrade both is lost. At my desktop PCs autodetection of inserted pluggable devices is lost sometimes after an upgrade. So I cannot confirm that you can wait a long time using a system where pacman told “reboot is needed”.

See above :slight_smile:

Try at the end something like that instead:

Exec = /usr/bin/bash -c 'echo -e "\e[1mREBOOT required!\e[";'

This will just output to terminal. All that gibberish around will make output bold, if i’m not mistaken.

Maybe best idea would be to just copy eos-reboot-required.hook under other name to hooks dir, after each update and change Exec line (to make sure the file is up to date and you don’t have to think about it, again for that simple operation you can use post-install hook with simple bash cp operation).

That’s however for post-install, not sure about pre-install cheker still

It needs small work because of I must use packages information from checkupdates but of pacman log but that is quite simple at all. I will go this way and possibly add packages to the list if I observe differences between notifying and pacman run.

ask @manuel if he is willing and has time he could help for sure

So it’s basically just a list of packages that need reboot after an update? Well, that’s a bit disappointing. But it makes it easy to check in a script.

This script will tell you whether reboot is necessary, with approximately the same accuracy as eos-update-notifier:

#!/bin/bash
# Check whether reboot is necessary after an update.
# dependency: checkupdates
UPDATES=$(checkupdates)
# assume packages containing these strings in name need reboot after updating
REBOOT="(ucode|cryptsetup|linux|nvidia|mesa|systemd|wayland|xf86-video|xorg)"

if [[ $UPDATES =~ $REBOOT ]]; then
  echo "Needs reboot"
  exit 0;
fi
echo "No reboot needed"
exit 1

EDIT: here is a much shorter script that does (almost) the same thing (just in case someone complains about inefficiency):

checkupdates | awk '/ucode/ || /cryptsetup/ || /linux/ || /nvidia/ || /mesa/ || /systemd/ || /wayland/ || /xf86-video/ || /xorg/ { print "Needs reboot."; exit }'

EDIT 2: simplified the code in the first example.

5 Likes

Thanks for that - I would have coded it in a similar way. Last question is “does pacman detect that in the same way?” I have looked at the installed files with pacman -Ql pacman and can’t find any hook for alpm that contains “reboot” and any file that contains such a package list…

It seems the answer to that is: no. It seems that pacman has no idea whether updating a package requires reboot or not.

It seems - but it is not. after pacman -Syu runs I see the message “Inform user to reboot”. Where does this message come from?