You are not logged in.

#1 2021-01-25 22:26:46

equalizer876
Member
Registered: 2018-09-11
Posts: 79

[SOLVED] Pacman hook to apply after initramfs update

Hello.
according to https://wiki.archlinux.org/index.php/Dm … _initramfs I need to "chmod 600" the initramfs, because there is a keyfile inside. Unfortunately after every initramfs update the permission is set back to 644. So how to automate the "chmod 600 ..."?

I tried a pacman hook like

[Trigger]
Type = Path
Operation = Install
Operation = Upgrade
Target = /usr/lib/modules/*/vmlinuz
Target = /usr/lib/initcpio/*

[Action]
Description = Updating initramfs permission...
When = PostTransaction
Exec = chmod 600 /boot/initramfs-linux*
NeedsTargets

but this hook never applies after the initramfs changes. How do I make this hook work?

Last edited by equalizer876 (2021-02-16 17:33:51)

Offline

#2 2021-01-25 22:41:54

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: [SOLVED] Pacman hook to apply after initramfs update

Systemd unit files aren't bash scripts, the command in your Exec= line isn't being parsed how you think it is....


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#3 2021-01-25 22:53:16

equalizer876
Member
Registered: 2018-09-11
Posts: 79

Re: [SOLVED] Pacman hook to apply after initramfs update

Thanks I forgot about that. Then I would need to do

Exec = /bin/bash -c 'chmod 600 /boot/initramfs-linux*'

Well, but it still wouldn't get called. When pacman -Syu updated "linux" then I never saw the past transaction hook with description "Updating initramfs permission...".

Offline

#4 2021-01-26 00:21:24

apg
Developer
Registered: 2012-11-10
Posts: 211

Re: [SOLVED] Pacman hook to apply after initramfs update

Paths refer to the files in the package archive; the installation root should not be included in the path.

You also don't need NeedsTargets

Offline

#5 2021-01-30 11:40:47

equalizer876
Member
Registered: 2018-09-11
Posts: 79

Re: [SOLVED] Pacman hook to apply after initramfs update

I changed the hook, but it still doesn't get triggered. hmm It's placed inside /etc/pacman.d/hooks

Last edited by equalizer876 (2021-01-30 11:41:28)

Offline

#6 2021-01-30 11:53:37

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,085

Re: [SOLVED] Pacman hook to apply after initramfs update

Does the filename end in .hook can you post the updated hook ?

Offline

#7 2021-01-30 12:16:42

equalizer876
Member
Registered: 2018-09-11
Posts: 79

Re: [SOLVED] Pacman hook to apply after initramfs update

/etc/pacman.d/hooks/initramfs_update.hook

[Trigger]
Type = Path
Operation = Install
Operation = Upgrade
Target = /boot/initramfs-linux*
Target = /usr/lib/modules/*/vmlinuz
Target = /usr/lib/initcpio/*

[Action]
Description = Updating initramfs permission...
When = PostTransaction
Exec = /bin/bash -c 'chmod 600 /boot/initramfs-linux*'

Offline

#8 2021-01-30 12:18:33

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,085

Re: [SOLVED] Pacman hook to apply after initramfs update

What apg wanted to point out with his quote was that your target paths should not include the root, so your Target definitions should look like:

Target = usr/lib/modules/*/vmlinuz
Target = usr/lib/initcpio/*

note the lack of a leading /

Offline

#9 2021-01-30 12:29:19

equalizer876
Member
Registered: 2018-09-11
Posts: 79

Re: [SOLVED] Pacman hook to apply after initramfs update

Thanks. I will try next time.

Now it works!

Last edited by equalizer876 (2021-02-16 17:34:04)

Offline

Board footer

Powered by FluxBB