Is there a way to automatically run a bash script after dietpi-update got triggered?
I want to use this to update my running docker containers.
Is there a way to automatically run a bash script after dietpi-update got triggered?
I want to use this to update my running docker containers.
dietpi-update && ./path/to/my_script.sh
No, there is no built-in way to trigger a custom script after running dietpi-update
. The way described by @Jappe could be an option, but I personally would not try to bundle both activities to update DietPi and Docker container. Why? Because you don’t know where the problem is coming from if the container doesn’t start afterwards. It is better to separate both actions and make sure that everything runs fine after the dietpi-update
and before updating the container.
There is also an feature in DKpg
called post-invoke
and post-invoke-success
where you can define a package as dependencie to trigger to post invoke action.
Simplest would be to create a drop-in config in /etc/apt/apt.conf.d/
with the content
DPkg::Post-Invoke { "/path-to/my-script"; };
See
https://man7.org/linux/man-pages/man1/dpkg.1.html
and
https://www.cyberciti.biz/faq/debian-ubuntu-linux-hook-a-script-command-to-apt-get-upgrade-command/
but for this you need an apt package update as trigger.
The post-invoke doesn’t need a trigger, as the example from cyberciti page shows.
ok understood. Still, I don’t think this is a good idea as each time he would run apt upgrade
(assuming it would be the trigger), the custom script would be executed.