Home » Questions » Computers [ Ask a new question ]

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

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

There's probably a MUCH more elgant way to solve this, but basically, i have a terribly minimal ubuntu system that connects to a wireless network. At the moment i'm using a script that calls wpa supplicant and dhclient, to connect. I'd like to have this automatic - but i've had no luck with /etc/network/interfaces, or getting the script i use to run on boot.

Asked by: Guest | Views: 64
Total answers/comments: 2
Guest [Entry]

"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."
Guest [Entry]

"Not sure if this works in all cases but heres my setup that seems to work fine.
I use a RaLink RT2500

auto wlan0
iface wlan0 inet static
wireless-mode managed
wireless-essid XXXXXXXXXXXX
wireless-key XXXXXXXXXX

#!/bin/sh -e
# rc.local
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will ""exit 0"" on success or any other
# value on error.
# In order to enable or disable this script just change the execution
# bits.
# By default this script does nothing.

#start wireless at boot - added by ckendall 20100304
ifup wlan0

exit 0"