Run script automatically after kernel upgrade ?
We would like to run our site specific scripts after each kernel upgrade. But would like to do it automatically.
Is it possible somehow to do that ?
Regards
Responses
I would roll a custom rpm package and put your script in the %triggerin section. This also makes it easy to deploy (and update) your site specific scripts across your site.
For example:
%triggerin -- kernel
place script here to run whenever package "kernel" is installed
For more information, see here:
http://rpm.org/api/4.4.2.2/triggers.html
Note: the kernel package isn't normally updated in rpm terms, but is normally treated as a new install with an older kernel package typically being uninstalled. This behaviour is described in yum.
I have made one assumption: you would like to do this after the host is updated and rebooted?
If I was in this position.. I would likely do the following:
create a "touch file" in the kernel directory of the running kernel at the end of your script
When the host reboots, it runs:
/etc/init.d/check_for_new_kernel
#!/bin/bash
# Exit script if the file matches the running kernel
test -f /lib/modules/`uname -r`/.isupdated && exit 0
# If last test failed, then run the following: (if successful, create new touch file, else exit 9)
/root/bin/update_after_kernel_upgrade.sh && touch /lib/modules/`uname -r`/.isupdated || exit 9
exit 0
You could either put that touch command in your update_script, or leave it in the check script (or both, I suppose).
If you don't have the kernel-devel package installed, you could do the same but change the location to somewhere else...
touch /root/.`uname -r`
or..
touch /var/lib/.`uname -r`
I would put it somewhere that would not be impacted by a cleanup script or something.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
