From dc101daef771eaab94ed00f87a69612e60c73c11 Mon Sep 17 00:00:00 2001 From: James Rayner Date: Sat, 29 Dec 2007 23:47:17 +1100 Subject: Small new features & tidying * Tidied: auto-wireless support * Added: Explicitly specify menu default via NETWORKS_MENU_DEFAULT * Added: Explicitly set menu timeout with NETWORKS_MENU_TIMEOUT * Added: Recording of last profile as $PROFILE_DIR/last * Tidied: /etc/rc.d/net-profiles --- contrib/netcfg-auto-wireless | 43 +++++++++++++++++++++++++++++++++++++++++++ contrib/netcfg-wireless-auto | 43 ------------------------------------------- 2 files changed, 43 insertions(+), 43 deletions(-) create mode 100755 contrib/netcfg-auto-wireless delete mode 100755 contrib/netcfg-wireless-auto (limited to 'contrib') diff --git a/contrib/netcfg-auto-wireless b/contrib/netcfg-auto-wireless new file mode 100755 index 0000000..036cd12 --- /dev/null +++ b/contrib/netcfg-auto-wireless @@ -0,0 +1,43 @@ +#! /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 + +# wifi_auto +# autoconnect wireless interface +# $1 - wireless interface + +wifi_auto() +{ + INTERFACE=$1; RETRIES=6 + + while read essid; do + # awfully long grep that finds a file which has: + # CONNECTION=wireless, ESSID=$essid, INTERFACE=$INTERFACE + profile=$(grep -rlP "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 + done < "$(list_networks $IFACE)" + + # If there's a profile, connect, else fail. + if [[ -n "$profile" ]]; then + netcfg2 $(basename $profile) + exit $? + else + err "No network found" + exit 1 + fi +} + +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 diff --git a/contrib/netcfg-wireless-auto b/contrib/netcfg-wireless-auto deleted file mode 100755 index 036cd12..0000000 --- a/contrib/netcfg-wireless-auto +++ /dev/null @@ -1,43 +0,0 @@ -#! /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 - -# wifi_auto -# autoconnect wireless interface -# $1 - wireless interface - -wifi_auto() -{ - INTERFACE=$1; RETRIES=6 - - while read essid; do - # awfully long grep that finds a file which has: - # CONNECTION=wireless, ESSID=$essid, INTERFACE=$INTERFACE - profile=$(grep -rlP "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 - done < "$(list_networks $IFACE)" - - # If there's a profile, connect, else fail. - if [[ -n "$profile" ]]; then - netcfg2 $(basename $profile) - exit $? - else - err "No network found" - exit 1 - fi -} - -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 -- cgit v1.2.3-24-g4f1b