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

Hi,

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 '127.0.0.1' &> /dev/null; do
		sleep 1
	done
1 Like

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.

1 Like

Ok, this seems to work:

boot()
{
  # Wait for the loopback interface to be ready
  ubus -t 30 wait_for network.interface network.loopback 2>/dev/null
  rc_procd start_service
}
1 Like