wireless.sh (873B)
1 #!/bin/sh 2 3 # remember to change your external wireless interface 4 ext_if=ath0 5 # number of seconds to wait for interface to connect, adjust accordingly 6 time=4 7 8 usage() { 9 echo "Usage: $0 [-h] [function1|function2]" 1>&2 10 } 11 12 downcmd() { 13 echo "Disconnecting from current wireless" 14 ifconfig $ext_if -nwid -wpakey -nwkey down 15 sleep $time 16 } 17 18 upcmd() { 19 echo "Connecting to new wireless" 20 ifconfig $ext_if nwid $NWID wpakey $WPAKEY up 21 sleep $time 22 } 23 24 function1() { 25 NWID=ssid 26 WPAKEY=pass 27 downcmd 28 upcmd 29 dhclient $ext_if 30 } 31 32 function2() { 33 NWID=otherssid 34 WPAKEY=pass2 35 downcmd 36 upcmd 37 dhclient $ext_if 38 } 39 40 # template() { 41 # NWID=ssid 42 # WPAKEY=pass 43 # downcmd 44 # upcmd 45 # dhclient $ext_if 46 # } 47 48 if test -z "$1" 49 then 50 usage 51 exit 1 52 fi 53 54 while : 55 do 56 case $1 in 57 -h) 58 usage 59 exit 0 60 ;; 61 function1) 62 function1 63 exit 0 64 ;; 65 function2) 66 function2 67 exit 0 68 ;; 69 esac 70 done