running a connection script on boot, on ubuntu, or using /etc/networks properly

Solution 1:

You want to edit /etc/network/interfaces so it automatically brings it up on boot. It should look something like this for your wireless:

iface wlan0 inet dhcp
wireless-key s:KEY
wireless-essid NETWORK_SSID

auto wlan0

replace KEY with your wireless key, and NETWORK_SID with your router's SSID.

If you wish to use your script on startup...

copy it to /etc/init.d (replace script path appropriately):

sudo cp /path/to/script /etc/init.d

make it executable (ensure it has a shebang line at the top, eg. #!/bin/bash):

sudo chmod +x /etc/init.d/script

add the default startup symbolic links:

sudo update-rc.d script defaults

you'll get output similar to the following:

Adding system startup for /etc/init.d/script ...
   /etc/rc0.d/K20script -> ../init.d/script
   /etc/rc1.d/K20script -> ../init.d/script
   /etc/rc6.d/K20script -> ../init.d/script
   /etc/rc2.d/S20script -> ../init.d/script
   /etc/rc3.d/S20script -> ../init.d/script
   /etc/rc4.d/S20script -> ../init.d/script
   /etc/rc5.d/S20script -> ../init.d/script

your script should now run at startup.