[Solved] Start init script at boot after localhost is ready


I want to start an init script at boot after the network (specifically localhost) is up.

Using START=95 at the top of the init script does not work.
I have added sleep loop, but this seems kind of an ugly solution:

start_service() {
       # wait for localhost
	while ! ip -4 a s dev lo | grep '' &> /dev/null; do
		sleep 1

Code in question: https://github.com/openwrt/packages/pull/5589

Any help is welcome.

Some packages like travelmate from @dibdot have used ubus wait logic to check for interface's presence:

You might maybe try something similar.

Ok, this seems to work:

  # Wait for the loopback interface to be ready
  ubus -t 30 wait_for network.interface network.loopback 2>/dev/null
  rc_procd start_service