You are not logged in.

#1 2023-03-31 02:52:04

landshark
Member
Registered: 2023-03-31
Posts: 2

[Solved] Print warning message if the running kernel is updated

Hi all,

I'm Stefan and I'm running the same Arch install for several years now (nice thing about Linux: plug the drive out of the old laptop and plug it in another one -> works).

It never occurred to me to register in this forum until now because I'm neater a newbie nor a pro. But now this has happened again...

My problem with pacman is that you cannot know by just casually looking at the output of pacman -Syu if you need to reboot. My laptop is suspended whenever I don't use it. Roughly 50 percent of my problems after an update result of me forgetting to reboot.

I was lazy so I asked ChatGPT about it and it came up with the following hook:

[Trigger]
Operation = Upgrade
Type = Package
Target = linux

[Action]
Description = Warn about kernel update
When = PostTransaction
Exec = /usr/bin/sh -c 'if pacman -Q linux | grep -q $(uname -r); then echo "WARNING: Kernel updated. Please reboot your system to ensure changes take effect."; fi'

Is it advisable to include such a hook (adding the possibility to infer the running kernel from uname) to the default install?

--
Cheers
Stefan

Last edited by landshark (2023-03-31 04:48:27)

Offline

#2 2023-03-31 02:58:15

schard
Forum Moderator
From: Hannover
Registered: 2016-05-06
Posts: 2,563
Website

Re: [Solved] Print warning message if the running kernel is updated

The Exec line is pure nonsense. It'll never output the warning.
Firstly the logic is inverted and secondly the version format of the package and uname never match due to a - vs . discrepancy.

130 ✗ srv ~ $ pacman -Q linux
linux 6.2.8.arch1-1
0 ✓ srv ~ $ uname -r
6.2.8-arch1-1

Furthermore the hook will just print another warning, i.e. noise during pacman's output.
I always consider rebooting the machine, when I see the initramfs being regenerated in the hooks.
No need for an additional message here.

Last edited by schard (2023-03-31 03:03:29)


Inofficial first vice president of the Rust Evangelism Strike Force

Offline

#3 2023-03-31 03:13:18

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,456
Website

Re: [Solved] Print warning message if the running kernel is updated

schard wrote:

I always consider rebooting the machine, when I see the initramfs being regenerated in the hooks.

Seconded.  I don't personally have any need to reboot when a kernel is upgraded, but it's pretty damned hard to miss the initramfs rebuild.  I'm not sure how one could miss than but still notice a single line warning message.  If you watch pacman's output you should already be fine - if you don't watch it at all, then adding another message sure wont help.

Last edited by Trilby (2023-03-31 03:14:10)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#4 2023-03-31 04:47:18

landshark
Member
Registered: 2023-03-31
Posts: 2

Re: [Solved] Print warning message if the running kernel is updated

schard wrote:

The Exec line is pure nonsense. It'll never output the warning.
Firstly the logic is inverted and secondly the version format of the package and uname never match due to a - vs . discrepancy.

130 ✗ srv ~ $ pacman -Q linux
linux 6.2.8.arch1-1
0 ✓ srv ~ $ uname -r
6.2.8-arch1-1

You are right, I missed that pacman has a dot and uname uses a hyphen ...

schard wrote:

Furthermore the hook will just print another warning, i.e. noise during pacman's output.
I always consider rebooting the machine, when I see the initramfs being regenerated in the hooks.
No need for an additional message here.

Trilby wrote:

if you don't watch it at all, then adding another message sure wont help

I see that maybe this is against the Arch way of doing things, but it got me serveral times where I was investigating problems which could be solved by a reboot.

But I get your hints, the truth is that I often don't look at the output of pacman after the update if there was no error. This is my problem and I will have a better look at the output in the future. Thanks for your replies

Offline

#5 2023-03-31 12:49:29

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,456
Website

Re: [Solved] Print warning message if the running kernel is updated

Wanting to adjust every bit of your system to make it more useful for your own use is not at all against the "arch way" - if anything it's a pretty good example of it.  But going through extra steps for no possible benefit (if you're not watching the output anyways) would be pretty silly.

In contrast, triggering an on-screen display (i.e., one of those popup notification things) or an email to you could make some sense for this use: if you miss the pacman output, you'd get a different indicator that you need to reboot.  However, if you are not watching pacman output at all, you are really opening yourself up to lots of other problems.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

Board footer

Powered by FluxBB