I have a command I want to run on every boot — it just sends an I2C command and exits. /etc/rc.local runs far too late in the boot process to put it in there (rc.local runs at S95 and I want it more like S10). I can't do this with procd because it expects the process to keep running indefinitely. Besides, it seems like it's not the sort of thing that procd or the init.d scripts are designed for.
Is there some way to do this, or at least shoehorn it into procd/init.d?
Or alternatively, you might have the command in a uci-defaults file.
Normally uci-defaults are deleted automatically after first successful completion, but that is controlled by the script exit code. Setting an error-like exit code (non-zero) would leave the script intact for the next boot.
I read about the boot() function on that page, but didn't really understand what it was saying. I'll try it out and see if that does what I need. Thanks!
Thanks @vgaetera - I had another look at rc.common which contains the functions init scripts are meant to shadow. It answered a couple of lingering questions I had such as:
there is also a shutdown() function, called on shutdown or reboot
both boot() and shutdown() can be used in a procd style init script too
your own override of boot() should probably call start "$@" at the end, and shutdown() should probably call stop (no args) at the start.
I updated the wiki's init scripts page as well as a few other places that point to it to include a bit more information on this. Let me know if anything's unclear.