[systemd-devel] System power control
David Lambert
dave at lambsys.com
Sun Aug 12 15:55:06 PDT 2012
I am developing a battery backed up cape for a Beaglebone project which
uses systemd under Angstrom. In order to conserve battery life, I would
like to signal my battery control hardware via a GPIO when system
shutdown is complete and all file systems have been dismounted. Is there
a "hook" in systemd which will allow me to call a small user helper
program at this point. Looking at the shutdown.c source, I see the
following code:
if (access("/run/initramfs/shutdown", X_OK) == 0) {
if (prepare_new_root() >= 0 &&
pivot_to_new_root() >= 0) {
execv("/shutdown", argv);
log_error("Failed to execute shutdown binary: %m");
}
}
Is the intention of this code to provide such a hook? Can I cheat by
creating /run/initramfs/ just prior to shutdown and copy a small
shutdown executable of my own here. This sounds like it may work, but
seems like a terrible hack. I feel that there should be a more elegant
way to achieve this goal.
Thanks for any advice.
Dave.
More information about the systemd-devel
mailing list