Service Doesn't Start on First Boot

I have a script, inside /etc/init.d, that doesn't run on first boot. I am calling /etc/init.d/myscript enable from uci-defaults and the symlinks are created correctly. However, it seems as if the newly created symlink is ignored on first boot (after flashing). Everything works fine, after a reboot. Does anyone have any idea what is going on here?

Some of the first boot process is executed towards the end of the standard boot process and therefore won't take effect until the next time the system is rebooted.

This enables the service on the next boot, but if it this command is executed after the boot process has progressed past this point, it won't retroactively start it. Instead, you may want to run this as well:
/etc/init.d/myscript start

Running both enable and start should ensure that the script is enabled for future boots, but that it does actually start 'now' (at the time of the execution).

1 Like

I was under the impression that uci-defaults run before any of the rc.d scripts. Is that incorrect?

Disabling a service, via a uci-defaults script, seems to always work. I can't understand why creating/enabling one doesn't. Could you dumb this part down for me, by any chance?

Edit: My understanding was wrong. I thought uci-defaults were handled by preinit or something at that level, but I just found that they are in fact handled by the boot init script (starts at 10). Thanks for setting me in the right direction, @psherman.

1 Like

The truth is that I cannot conclusively say when your script would be executed. Obviously some firstboot items are absolutely required early in the process (such as generating the basic network and wireless files), but I suspect that other things happen later.

What if you add a logger statement - then you can see when, relative to other startup tasks, this actually executes.

Yeah, uci-defaults are not preinit stuff.
"boot" runs them at priority 10 like you noticed, and the last priority is supposed to be "done" at 95, which runs the /etc/rc.local. There are a few init scripts that deviate from that range (priorities after 95), but in general the init scripts priorities should be between those (from 11 to 94).

Note that some of init scripts launch subprocesses and take long to complete, so it is not guaranteed that a script at 15 is wholly completed before something at 20 gets launched.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.