summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJames Rayner <james@archlinux.org>2008-01-06 05:15:42 +0100
committerJames Rayner <james@archlinux.org>2008-01-06 05:15:42 +0100
commit4997f3a7b48c41f6b4a78e11210106037545ddc2 (patch)
treec6f1bc4b36370e275104a7526573849057dfe223 /src
parent9f37f0b195fd75dd8a940f6478c5dcee8a5db4e3 (diff)
downloadnetctl-4997f3a7b48c41f6b4a78e11210106037545ddc2.tar.gz
netctl-4997f3a7b48c41f6b4a78e11210106037545ddc2.tar.xz
Added "automatic wireless" support and sort of 'cleaned' up rc.d/net-profiles
Diffstat (limited to 'src')
-rwxr-xr-xsrc/net-profiles98
-rw-r--r--src/wireless.subr3
2 files changed, 56 insertions, 45 deletions
diff --git a/src/net-profiles b/src/net-profiles
index f9c2875..d9cc4da 100755
--- a/src/net-profiles
+++ b/src/net-profiles
@@ -4,52 +4,62 @@
. /etc/rc.d/functions
case "$1" in
- start)
- if ! ck_daemon net-profiles; then
- echo "Network Profiles are already running. Try '/etc/rc.d/net-profiles restart'"
- exit
- fi
+ start)
+ if ! ck_daemon net-profiles; then
+ echo "net-profiles has already been started. Try '/etc/rc.d/net-profiles restart'"
+ exit
+ fi
- # Ensure any device renaming has occurred as intended
- for daemon in "${DAEMONS[@]}"; do
- if [ "$daemon" = "${daemon#!}" -a "$daemon" = "net-rename" ]; then
- if ck_daemon net-rename; then
- /etc/rc.d/net-rename start
- fi
- fi
- done
+ # Ensure any device renaming has occurred as intended
+ for daemon in "${DAEMONS[@]}"; do
+ if [ "$daemon" = "${daemon#!}" -a "$daemon" = "net-rename" ]; then
+ if ck_daemon net-rename; then
+ /etc/rc.d/net-rename start
+ fi
+ fi
+ done
- # $NET env var is passed from the kernel boot line
- [ ! "$NETWORKS_MENU_TIMEOUT" ] && NETWORKS_MENU_TIMEOUT=5
+ # $NET env var is passed from the kernel boot line
+ [ ! "$NETWORKS_MENU_TIMEOUT" ] && NETWORKS_MENU_TIMEOUT=5
+
+ if [[ "$NET" = "menu" ]]; then
+ /usr/bin/netcfg-menu $NETWORKS_MENU_TIMEOUT
+ elif [[ "$NET" ]]; then
+ /usr/bin/netcfg2 -c $NET
+ else
+ # No NET= passed at boot, go to NETWORKS=()
+ for network in ${NETWORKS[@]}; do
+ case $network in
+ menu) # Pull up menu of networks
+ /usr/bin/netcfg-menu $NETWORKS_MENU_TIMEOUT
+ ;;
+ auto-*) # Automatic configuration, store type and get interface next
+ auto=$network
+ ;;
+ *) # Either interface or profile
+ if [[ "$auto" ]]; then # Auto set, so interface
+ /usr/bin/netcfg-$auto $network
+ unset auto
+ elif [ "$network" = "${network#!}" ]; then # otherwise profile
+ /usr/bin/netcfg2 -c $network
+ fi
+ ;;
+ esac
+ done
+ fi
- if [ "$NET" = "menu" -o "$NETWORKS" = "menu" ]; then
- /usr/bin/netcfg-menu $NETWORKS_MENU_TIMEOUT
- elif [ "$NET" ]; then
- /usr/bin/netcfg2 $NET
- elif [ "${NETWORKS[0]}" = "auto-wireless" ]; then
- if [ "${NETWORKS[1]}" ]; then
- /usr/bin/netcfg-auto-wireless ${NETWORKS[1]}
- fi
- elif [ "$NETWORKS" ]; then
- for prof in ${NETWORKS[@]}; do
- if [ "$prof" = "${prof#!}" ]; then
- /usr/bin/netcfg2 -c $prof
- fi
- done
- fi
-
- add_daemon net-profiles
- ;;
- stop)
- # shutdown any profiles started by netcfg (or from NET_PROFILES in rc.conf)
- /usr/bin/netcfg2 -a
- rm_daemon net-profiles
- ;;
- restart)
- $0 stop; sleep 1; $0 start
- ;;
- *)
- echo "usage: $0 {start|stop|restart}"
+ add_daemon net-profiles
+ ;;
+ stop)
+ # shutdown any profiles started by netcfg (or from NET_PROFILES in rc.conf)
+ /usr/bin/netcfg2 -a
+ rm_daemon net-profiles
+ ;;
+ restart)
+ $0 stop; sleep 1; $0 start
+ ;;
+ *)
+ echo "usage: $0 {start|stop|restart}"
esac
-# vim: set ts=2 noet:
+# vim: set ts=4 et sw=4:
diff --git a/src/wireless.subr b/src/wireless.subr
index fb81ff5..3e7f6fd 100644
--- a/src/wireless.subr
+++ b/src/wireless.subr
@@ -65,7 +65,8 @@ list_networks()
[[ -z "$1" ]] && return 1
essids=$(mktemp /tmp/essid.XXXXX)
- let try 0;
+ let try=0;
+ RETRIES=6;
while [[ $try -ne $RETRIES ]]; do
iwlist $1 scan 2> /dev/null|grep ESSID|sed 's/.*ESSID:"\([^"]\+\)".*/\1/' > $essids
sleep 0.5; let try++