Simple Wifi Script

Hi,

I have created a simple wifi script for enable/disable wireless on my openmoko.

This script will put a icon on the desktop.

HOWTO START:

Before use the script you must configure 2 files.

/etc/network/interfaces (Open the file, and add one line)

*** start of file ****
# Wired or wireless interfaces
iface eth0 inet dhcp

Add this line:
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
*** end of file ****

Every time you do ifup eth0, network will use this file (/etc/wpa_supplicant/wpa_supplicant.conf) for find your wireless network.

/etc/wpa_supplicant/wpa_supplicant.conf (create a new file - sample file from openmoko wiki)

*** start of file ****
ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=0
eapol_version=1
ap_scan=1
fast_reauth=1
# WPA2:
network={
ssid=”your ssid”
scan_ssid=1
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=TKIP CCMP
psk=”secret key”
priority=50
}

# WPA:
network={
ssid=”your_ssid”
proto=WPA
key_mgmt=WPA-PSK
pairwise=TKIP
group=TKIP
scan_ssid=1
psk=”secret key”
priority=10
}

# WEP:
network={
ssid=”your_ssid”
scan_ssid=1
key_mgmt=NONE
wep_tx_keyidx=0
wep_key0=your_hex_key
priority=8
}

# Open:
network={
ssid=”your ssid”
key_mgmt=NONE
priority=5
}
*** end of file ****

HOWTO END:

After wpa is configured, its only necessary use 2 commands, for put wireless up and down.

Wifi Up - ifdown usb0 && ifup eth0
Wifi Down - ifdown eth0 && ifup usb0

You can download here with all files and a install script too.

All script files will be put on /usr/local/bin and /usr/local/etc

That’s All

Leave a Reply