Re: Script to connect to internet at bootup

Le 05/03/2011 02:26, Fajar Priyanto a écrit :
On Sat, Mar 5, 2011 at 3:48 AM, Olivier Cailloux
<olivier.cailloux@xxxxxxxxx> 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.
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 -O /tmp/> /dev/null if [ ! -s
/tmp/ ];then echo "no" else echo "yes" fi

Read more:

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

I tried the following script, which does not work.
echo "${0}" start > /home/olivier/Logiciels/FBL-wg-auth-out.log
wget --tries=10 --retry-connrefused --timeout=5 1>> /home/olivier/Logiciels/FBL-wg-auth-out.log 2>> /home/olivier/Logiciels/FBL-wg-auth-err.log
if [ "$?" -ne "0" ]; then
echo "Wget failed, ending." >> /home/olivier/Logiciels/FBL-wg-auth-err.log
echo "Wget succeeded, continuing." >> /home/olivier/Logiciels/FBL-wg-auth-out.log
curl (...)
echo "${0}" end >> /home/olivier/Logiciels/FBL-wg-auth-out.log
Does not work because wget considers a DNS error as a permanent error and does not retry after the first failure.

So one way to go would be to further explore that suggestion by testing in some loop, or with some other tools, whether the DNS resolves (some hints are given on the page you suggested). Or simply run my curl command repeatedly in a loop until it works (with a limit on the number of tries). I'll do this if I don't get any better suggestion on this list.

However my one-line script is becoming more and more complex, it feels strange to me to have to manually implement a check in a loop just to specify a dependency on the DNS service. I still wonder if I could use something like the dependency mechanism init.d uses (AFAIU), or anything of the same kind.

(Note that my question is not only about solving my specific current problem but also about learning how to effectively script things on a linux system.)

ubuntu-users mailing list
Modify settings or unsubscribe at:

Relevant Pages

  • Re: Is there a way to forward only email to to a s
    ... Also on this site there is a way to test if your script ... map to in DNS ... you for helping us to solve our SBS problems. ... I have other people on Verizon and they can send to users. ...
  • Re: Dynamic DNS management
    ... One of the irritations is that with a dynamic DNS, ... the IP addresses for the authoritative DNS server of multiple domains ... In the script, the above line is repeated for each domain; ... Perl has very good pattern matching. ...
  • Solaris tuning
    ... new DNS infrastructure. ... behavior for me) that needs to be increased so this script can take ... server ... def start: ...
  • nsupdate(8) rc.d Script
    ... Subject: nsupdaterc.d Script ... As I was setting up DNS for IPv6 on a test network, ... And the script is not optimized to do the updates in the ...
  • Re: script to listen
    ... You can either create your script and schedule it or do a loop. ... periodically monitor free disk space until the amount of free disk space ... To create a loop that runs forever, you simply specify a loop condition that ...