Running a script whilst dnf.automatic update
hi Redhat community !
I'm running automatic update on my RHEL8 servers with the dnf.automatic service using a systemd timer.
I need to run a small script before the update, to log the update output in a file and then after the update to run another script to check if a reboot is needed and then to reboot the server if needed.
To do so, I modified the file /usr/lib/systemd/system/dnf-automatic.service by replacing :
ExecStart=/usr/bin/dnf-automatic /etc/dnf/automatic.conf --timer
by
ExecStart=/etc/my_update_script.sh
and in my_update_script.sh,
I have :
#!/bin/bash /etc/pre_update.sh /usr/bin/dnf-automatic /etc/dnf/automatic.conf --timer > /var/log/auto-updates/`date +%Y-%m-%d-%H-%M`.log /etc/update_motd.sh /etc/reboot_script.sh
It's working fine but it looks like a recent update modified the file /usr/lib/systemd/system/dnf-automatic.service and set the ExecStart to default.
How can I do to prevent this ?
Is there another way to do what I want to do ?
I saw there is a command section in /etc/dnf/automatic.conf but I didn't success to use it.
Thanks for your help !
Responses