1

I have a debian package that I'm running on startup.

I'm using upstart and I think I need to add a dependency to the upstart config:

start on someProgram

I'm not sure which program, but I'm not using network-manager, it's disabled. I'm doing something like this:

ethernet=$(ifconfig -a | grep Ethernet | grep ^e | cut -d' ' -f1)
wifi=$(ifconfig -a | grep wl | cut -d' ' -f1)
ping -I $ethernet -c 1 8.8.8.8 \
  || ping -I $wifi -c 1 8.8.8.8 \
  || echo "not online"

Problem is ifconfig doesn't always show the $wifi interface because the program has turned on too early in the startup process.

Also ping -I $ethernet -c 1 8.8.8.8 fails when it should succeed.

If I do sleep 30 then ping it works fine.

Does anyone know what package I should be waiting for to get this to work as expected?

I'm using Ubuntu 14.04 on an embedded device.

3.0.36+ #16 SMP PREEMPT Tue Oct 31 19:17:57 EDT 2017 armv7l armv7l armv7l GNU/Linux

I thought I had an answer:

I'm finding that the network interfaces can be referenced directly instead of a package:

start on (local-filesystems and net-device-up IFACE!=lo)

I'd still like to improve it slightly for my case.

Since I'd rather wait for wlan than eth but I'm not sure if I can use a wild card like: IFACE=wlan*

But it seems this doesn't wait for the interface to be available to ifconfig instead it waits for that interface to have an active Internet connection.

0

I ended up finding a workaround using an upstart pre-start script:

pre-start script
    while [ -z "$(ifconfig | grep wlan)" ]
    do
        sleep 1
    done
    sleep 5
end script

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.