diff options
author | James Rayner <james@archlinux.org> | 2008-12-18 12:06:56 +0100 |
---|---|---|
committer | James Rayner <james@archlinux.org> | 2008-12-18 12:06:56 +0100 |
commit | 4278b9e04952c24b14ce5eb3b5ed25885129a859 (patch) | |
tree | 9438fce666c458b6417e958baaafd75721bedf94 /src-wireless/netcfg-auto-wireless | |
parent | d68313a616c8a4b46ae6192e966176aab3bdd49b (diff) | |
download | netctl-4278b9e04952c24b14ce5eb3b5ed25885129a859.tar.gz netctl-4278b9e04952c24b14ce5eb3b5ed25885129a859.tar.xz |
Arrange tree for future packaging
Diffstat (limited to 'src-wireless/netcfg-auto-wireless')
-rwxr-xr-x | src-wireless/netcfg-auto-wireless | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src-wireless/netcfg-auto-wireless b/src-wireless/netcfg-auto-wireless new file mode 100755 index 0000000..e5e4fc1 --- /dev/null +++ b/src-wireless/netcfg-auto-wireless @@ -0,0 +1,58 @@ +#! /bin/bash +# Originally contributed by Neuro: http://bbs.archlinux.org/viewtopic.php?pid=278148#p278148 + +. /usr/lib/network/network.subr +. /usr/lib/network/wireless.subr +. /etc/rc.conf +. /etc/rc.d/functions + +# wifi_auto +# autoconnect wireless interface +# $1 - wireless interface +wifi_auto() +{ + interface=$1; RETRIES=6 + stat_busy "Scanning for networks" + + ifconfig $interface up + networks="$(list_networks $interface)" + + if [[ ! "$networks" ]]; then + stat_append "- No networks available." + stat_fail + exit 1 + fi + + # Loop through all the found essid's, then find a matching profile. + while read essid; do + for network in $(list_profiles); do + load_profile $network + if [[ "$CONNECTION" = "wireless" && "$essid" = "$ESSID" && "$interface" = "$INTERFACE" ]]; then + found=$network + fi + # Clear out any variables set by the profile + . /usr/lib/network/${CONNECTION}.subr + ${CONNECTION}_clean_scope + done + done < $networks + + if [[ "$found" ]]; then + netcfg2 $found + exit $? + fi + + stat_append "- No profiles matched the found networks" + stat_fail + exit 1 +} + +if [[ $(id -u) -ne 0 ]]; then + err "This script needs to be run with root priviledges" + exit 1 +fi +if [[ -z $1 ]]; then + err "Please supply an interface to connect" + exit 1 +fi +wifi_auto $1 + |