Hello folks,

Thanks for the robust and insightful responses here; I'd like to summarize:

--  nickgeovanis suggested using ansible; this is a good insight, but
I do have the sense that it's overkill for my use case (if you're
provisioning 1000 identical machines, deploying this playbook by hand
or with anacron once is probably the way to go, but each of my dozen
machines is different, and I'd like to set it and forget it).

-- tomas suggests a very specific screwdriver, which I had also come
across in my googling; my confusion there was the one highlighted by
wanderer, which was "Does this run after every apt invocation, or only
the one that touched the relevant package?"  David Wright and the
wanderer both suggest a workaround, which essentially comes down to
wrapping apt in another script that's something like:
```
apt dist-upgrade
if /boot/grub/config changed:
   /usr/bin/sh clean_up_grub
```
which certainly would work, but also dances around the issue.
wanderer also brings up issues of changing the packages locally on my
install, which (in my case) is a recipe for pain.

Darac Marjal suggested looking at locally configuring grub, which is
ultimately what I ended up doing, and testing this by reinstalling
grub and watching apt reinstall it directly to all the relevant
drives.

So ultimately, my problem is addressed; however, the larger question
is still open: is there in fact a straightforward way for a user, not
the package maintainer, to tell the package management system: "If and
only if your operation touched package x, also do this one thing
locally."?  I can think of about a million use cases for this: "if you
touched maildir-utils, run mu  index." "if you touched offlineimap,
run offlineimap" "if you touched etckeeper, re-commit the /etc files"
and so on ...

Either way, thanks kindly, folks!

On Sat, Jun 14, 2025 at 7:10 PM Boyan Penkov <boyan.pen...@gmail.com> wrote:
>
> Hello folks,
>
> I'm wiring to ask how to get apt to run a script after a particular
> package is installed or updated.  Am I looking for dpkg-triggers or
> some apt conf?
>
> Specifically, I have GRUB installed to *every* drive, with the
> expectation that all but one drives can fail and the machine will
> still boot (to something...).  To this end, after I see apt has
> updated grub, I manually run something like:
> ```
> sudo update-grub
> sudo grub-install /dev/sda
> sudo grub-install /dev/sdb
> sudo update-grub
> ```
> I'd like to automate this; if grub is changed, run this script automatically.
>
> Thanks kindly, and cheers!
>
> --
> Boyan Penkov



-- 
Boyan Penkov

Reply via email to