Reboot and / or Shutdown script to run if anything causes reboot unintentially
I was just wondering for a solution regarding unintentially reboot.
My problem is, I would like to know if anything other than my script: OS or other scripts initiate a reboot sequence I want my script to notice that and interrupt reboot, and do some stuff and continue reboot/shutdown.
Could this possible?
And one another question, can I leave some ports as it is (output high or low, not pwm) during reboot?
@esunayg Unfortunately, I am unable to give any definitive response to your first question regarding catching shutdown/reboot to carry out some commands.
I believed it should be possible via relevant entries in /etc/init.d and /etc/rc.d and this is largely born out by information that can be found in https://wiki.openwrt.org/doc/techref/process.boot and https://wiki.openwrt.org/doc/techref/initscripts
However, as yet I have not managed to get anything along these lines to work - I am eventually going to need something like that - I will probably come back to investigate further later, but meanwhile I hope the references may help.
Associated with this, note:
- Any commands in /etc/rc.local are executed when the system boots
- Any commands in /etc/profile are executed when you log on
Regarding whether or not GPIO pins maintain there state over a reboot (obviously they would be lost over power off/power on), my testing suggests that, unfortunately, NO - they are not preserved over a reboot. I tried setting GPIO pins as outputs with specific output states and then doing a reboot. After the reboot the pins did NOT have the same state as before.
Thank you @kit-bishop,
I will read them.