Script to connect to internet at bootup

Olivier Cailloux olivier.cailloux at gmail.com
Fri Mar 4 02:18:59 UTC 2011


Hello list,

In the building where I live we have a bit of a "special" Internet 
access, i.e. we need to authenticate on an Internet page at a given URL. 
This is a simple HTML POST. It must be done at about each boot up. I 
have no idea how the network "knows" that I rebooted my computer, but 
apparently it knows as if I don't re-authenticate I have no Internet 
access. Anyway, that's not the point.

I'd like to have a script that authenticates me each time I (re)boot. 
Writing the script is not a problem: just a curl command. However, I 
wonder how to set up my system so that the script is run at every boot, 
and at the correct time, e.g. the DNS service must be loaded otherwise 
curl simply fails. Currently I have put the script in /etc/profiles.d/, 
but it often ends up being run too soon. I'd like to find some clean 
solution, in line with the usual administrator best practices. The 
script should be set up system wide, not for my personal use only. Maybe 
that involves adding the script to init.d and set up the dependencies 
right? Is there an alternative way that would be considered cleaner (or 
simpler)? If that is indeed the way to go, which exactly is the 
dependency? (I should be able to state that the script must be run "only 
when the network is ready", but I don't know what that exactly means wrt 
the available services.) Also, how to turn a simple one-line command 
into an init.d script? I can copy a daemon file from an other service 
and tweak it for my usage but 1) it seems unneedingly complex compared 
to the fact that what I want to run is a simple command; 2) these are 
daemon startup scripts, where a lot of options do not make sense for my 
simple script (e.g. my script can't be "stopped" or "restarted", only 
being "run").

Any reference to a tutorial on that subject or advices would be appreciated.
Olivier





More information about the ubuntu-users mailing list