Script to connect to internet at bootup

Fajar Priyanto fajarpri at arinet.org
Sat Mar 5 01:26:59 UTC 2011


On Sat, Mar 5, 2011 at 3:48 AM, Olivier Cailloux
<olivier.cailloux at gmail.com> wrote:
> Also the script works if I set a delay of 15 seconds before running it. But
> I'd like to find some clean way of configuring this, that is, I'd like to be
> able to specify to run the script only when "everything needed" (meaning, I
> guess: the DNS system) is ready. That's why I thought I'd use the dependency
> mechanism of init.d (see above the original post), but there may exist
> better approaches.
> Olivier

So, you are correct. It's timing issue. Delaying the script makes it work.
Well, if you don't want to use the delay method, we can use command to
resolve something, and if it doesn't succeed, keep trying until
successful, then run the authenticate script.

Some example I found in the net:
WGET="/usr/bin/wget" $WGET -q --tries=10 --timeout=5
http://www.google.com -O /tmp/index.google &> /dev/null if [ ! -s
/tmp/index.google ];then echo "no" else echo "yes" fi

Read more: http://www.linuxscrew.com/2009/04/02/tiny-bash-scripts-check-internet-connection-availability/#ixzz1FgTn9iYo

Also, I think better write all those thing in a separate script and
call it through rc.local instead for tidiness.




More information about the ubuntu-users mailing list