General TC > General TC Talk
Run a script as the last thing during shutdown
gilphilbert:
Thanks for the help here, it's really appreciated
I suspected that changing system scripts wouldn't be smiled upon. I don't like the idea of doing it either - even for personal scripts it feels a bit... hacky. The problem is that my command will cut power to the device, so nothing else will (ever) be run after that command. This is why I want it to be at the end of the shutdown process.
Thinking about the problem differently, I could use the gpio-poweroff overlay in config.txt, which should work for my purposes. It's not ideal, but I can make it work. That said, now I need to modify that file... again, not ideal. My script includes a configuration portion that would need to mount the boot filesystem, edit config.txt and then umount it. I don't suppose that would be accepted into the repos?
Paul_123:
So your talking Raspberry pi.
The gpio-shutdown overlay can be used to handle the shutdown event activities, Then the gpio-poweroff will change the state of a gpio pin after system halt (And I believe after the 10 flashes of the power LED to indicate the system is down.
We won't be enabling things like that in our standard images. It feels like you just need to make your own images.
To curaga's point above. The Raspberry pi bootloader supports multiple initrd's, we already supply two in the RPi images. So you can easily concatenate a third initrd in the config.txt. The only catch is that the initramfs line has to be 80 characters or less.
gilphilbert:
Actually, I would rather this applied to any single board computer rather than just the Raspberry Pi. I was just trying to think outside of the box for a moment.
I've built a hardware device - a power manager for single board computers. One of the things it does it cuts off power to the board when a given pin goes high (usually at the end of the shutdown sequence). For systemd-based systems, this is achieved with a script that runs at the very end of the halt process - meaning it will work with not just Raspberry Pi OS, but also with Armbian, etc. to support any SBC that has GPIOs (which is all of them). I'm currently using it with a Raspberry Pi and a NanoPi Neo and it works perfectly, but TCL has got me stumped because - not unreasonably - it's hard to add something to the very end of the shutdown sequence that doesn't require custom builds.
Navigation
[0] Message Index
[*] Previous page
Go to full version