#!/bin/bash WLANIF=rausb0 ENCTYPE=$1 SSID=$2 KEY=$3 DHCP=$4 wep_connect() { ifconfig $WLANIF down ifconfig $WLANIF up iwconfig $WLANIF essid $SSID iwconfig $WLANIF mode Managed iwpriv $WLANIF set AuthMode=WEPAUTO iwpriv $WLANIF set EncrypType=WEP iwpriv $WLANIF set Key1=$KEY ip_assign } wpa_connect() { ifconfig $WLANIF down ifconfig $WLANIF up iwconfig $WLANIF essid $SSID iwconfig $WLANIF mode Managed iwpriv $WLANIF set AuthMode=WPAPSK iwpriv $WLANIF set EncrypType=TKIP iwpriv $WLANIF set WPAPSK=$KEY ip_assign } wpa2_connect() { ifconfig $WLANIF down ifconfig $WLANIF up iwconfig $WLANIF essid $SSID iwconfig $WLANIF mode Managed iwpriv $WLANIF set AuthMode=WPA2PSK iwpriv $WLANIF set EncrypType=AES iwpriv $WLANIF set WPAPSK=$KEY ip_assign } ip_assign(){ if [ "$DHCP" = "s" ] then set_static else dhclient $WLANIF fi finalize } set_static() { echo "Enter IP:" read ip echo "Enter netmask:" read netmask ifconfig $WLANIF $ip netmask $netmask up } finalize() { iwconfig $WLANIF ifconfig $WLANIF exit 0 } error_text() { echo "Syntax:" echo "rt73wifi [wep|wpa|wpa2] SSID KEY [s]" echo "SSID = Network SSID" echo "KEY = Network Key" echo "If \"s\" is present, you will be prompted for a static IP" } if [ "$1" = "wep" ] then wep_connect fi if [ "$1" = "wpa" ] then wpa_connect fi if [ "$1" = "wpa2" ] then wpa2_connect fi error_text exit 0