I need to find a way to somehow intercept the halt
and reboot
commands and execute different actions via shell script before the actual halt
and reboot
commands are executed. Is that possible without writing a kernel module for that?
Here is the entire scenario. On a Raspberry Pi I have some external hardware connected to the GPIO pins. I would like to notify said hardware when the Raspberry Pi:
- Reboots, by pulsing one GPIO for a certain period.
- Is shutting down, by pulling the GPIO low permanently before the CPU is actually halted.
I already thought about putting a script into rc.d/
, but I have no idea how to figure out if the system is halting or only rebooting from within the script, when it is being executed.
Any thoughts?
reboot
one), what about a trojan-like approach? If for an user level to do some alias, if for the whole system to change the executable/sbin/halt
in/sbin/halt.binary
and to put your scripts instead if the/sbin/halt
?