[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Run script after package install, update



On Sun, Jun 15, 2025 at 12:14:30 -0500, David Wright wrote:
> Well, I just plagiarised /etc/apt/apt.conf.d/99needrestart:
> 
>   $ cat /etc/apt/apt.conf.d/99redogrub 
>   DPkg::Post-Invoke {"test -x /var/local/bin/redo && /var/local/bin/redo || true"; };
>   $ 
> 
> and wrote /var/local/bin/redo:
> 
>   $ cat /var/local/bin/redo 
>   #!/bin/sh
>   if [ "/boot/grub/grub.cfg" -nt "/var/local/bin/redo" ]; then
>     grub-mkconfig -o /boot/grub/grub.cfg
>   fi
>   touch "/var/local/bin/redo"
>   #

Looks reasonable.  The only thing you might want to take note of is the
-nt operand in /bin/sh's test command.  It's in the 2024 edition of POSIX,
but it's not in the previous edition, so one shouldn't expect it to be
present in shells that are more than half a year old.

Dash (in Bookworm) happens to include it, as well as bash, which is why it 
works here.  It's just not as portable as you might have thought.

I'm not sure why you've got scripts under /var, though.  That's weird.


Reply to: