commit 601e7e8f5e3989fe35caf9a953e352c95074ff6b parent 9f4beea87152bc1fcec790bc5fbbdc40e0a3caea Author: cipher <haris@2f30.org> Date: Fri, 28 Mar 2014 14:06:35 +0200 Simple script for managing wireless interface Diffstat:
A | wireless.sh | | | 70 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1 file changed, 70 insertions(+), 0 deletions(-)
diff --git a/wireless.sh b/wireless.sh @@ -0,0 +1,70 @@ +#!/bin/sh + +# remember to change your external wireless interface +ext_if=ath0 +# number of seconds to wait for interface to connect, adjust accordingly +time=4 + +usage() { + echo "Usage: $0 [-h] [function1|function2]" 1>&2 +} + +downcmd() { + echo "Disconnecting from current wireless" + ifconfig $ext_if -nwid -wpakey -nwkey down + sleep $time +} + +upcmd() { + echo "Connecting to new wireless" + ifconfig $ext_if nwid $NWID wpakey $WPAKEY up + sleep $time +} + +function1() { + NWID=ssid + WPAKEY=pass + downcmd + upcmd + dhclient $ext_if +} + +function2() { + NWID=otherssid + WPAKEY=pass2 + downcmd + upcmd + dhclient $ext_if +} + +# template() { +# NWID=ssid +# WPAKEY=pass +# downcmd +# upcmd +# dhclient $ext_if +# } + +if test -z "$1" +then + usage + exit 1 +fi + +while : +do + case $1 in + -h) + usage + exit 0 + ;; + function1) + function1 + exit 0 + ;; + function2) + function2 + exit 0 + ;; + esac +done