summaryrefslogtreecommitdiffstats
path: root/contrib/netcfg-auto-wireless
diff options
context:
space:
mode:
authorJames Rayner <james@archlinux.org>2008-05-30 14:22:35 +0200
committerJames Rayner <james@archlinux.org>2008-05-30 14:22:35 +0200
commit10d1c069a4e38ccbcaaa893d2d9e28ad5e05aae1 (patch)
treec61fb416dcca62750ac37cf5fa6de6068914344c /contrib/netcfg-auto-wireless
parentdcc9f2bfacb27cbabee1d5487d84087d99207e2a (diff)
downloadnetctl-10d1c069a4e38ccbcaaa893d2d9e28ad5e05aae1.tar.gz
netctl-10d1c069a4e38ccbcaaa893d2d9e28ad5e05aae1.tar.xz
FS9953 FS9644
Diffstat (limited to 'contrib/netcfg-auto-wireless')
-rwxr-xr-xcontrib/netcfg-auto-wireless40
1 files changed, 21 insertions, 19 deletions
diff --git a/contrib/netcfg-auto-wireless b/contrib/netcfg-auto-wireless
index 5660dcd..e5e4fc1 100755
--- a/contrib/netcfg-auto-wireless
+++ b/contrib/netcfg-auto-wireless
@@ -5,17 +5,17 @@
. /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
+ interface=$1; RETRIES=6
stat_busy "Scanning for networks"
- ifconfig $INTERFACE up
- networks="$(list_networks $INTERFACE)"
+ ifconfig $interface up
+ networks="$(list_networks $interface)"
if [[ ! "$networks" ]]; then
stat_append "- No networks available."
@@ -23,25 +23,27 @@ wifi_auto()
exit 1
fi
+ # Loop through all the found essid's, then find a matching profile.
while read essid; do
- # awfully long grep that finds a file which has:
- # CONNECTION=wireless, ESSID=$essid, INTERFACE=$INTERFACE
- profile=$(grep -rlP --exclude=/etc/network.d/last "CONNECTION=\"?wireless\"?(\n|.)*INTERFACE=\"?$INTERFACE\"?(\n|.)*ESSID=\"?$essid\"?" $PROFILE_DIR/|head -n 1)
- if [[ -n "$profile" ]]; then
- break # If we found a profile, use it.
- fi
+ 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 there's a profile, connect, else fail.
- if [[ -n "$profile" ]]; then
- stat_done
- netcfg2 $(basename $profile)
- exit $?
- else
- stat_append "- No profiles matched the found networks"
- stat_fail
- exit 1
+ 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