base-files: attempt bring up related wifi devices when calling ifup If a user invoked...
authorJo-Philipp Wich <jow@openwrt.org>
Fri, 22 Jul 2011 00:21:20 +0000 (00:21 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Fri, 22 Jul 2011 00:21:20 +0000 (00:21 +0000)
The changeset modifies the "ifup" command to search for related wireless
devices and call "wifi up" on them if applicable. This way the commands for
wireless and non-wireless interfaces are unified from a cli point of view.

The "ifup -a" case has not been changed to keep the logic of the
/etc/init.d/network boot sequence. This might be changed later.

Solves #9763.

SVN-Revision: 27720

package/base-files/Makefile
package/base-files/files/sbin/ifdown
package/base-files/files/sbin/ifup

index 9cac1f058b93c4e21e4d284e1a3ec8ff0b9697df..5553c99afb6d1399d918a910e0285b3081f1503e 100644 (file)
@@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
 include $(INCLUDE_DIR)/kernel.mk
 
 PKG_NAME:=base-files
 include $(INCLUDE_DIR)/kernel.mk
 
 PKG_NAME:=base-files
-PKG_RELEASE:=76
+PKG_RELEASE:=77
 
 PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/
 PKG_BUILD_DEPENDS:=opkg/host
 
 PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/
 PKG_BUILD_DEPENDS:=opkg/host
index 92cdfd2b02460ebce247d44ea6b8bc6936714537..1455a9de77a8b74ad14af6fb3278257618eb631e 100755 (executable)
@@ -1,16 +1,20 @@
 #!/bin/sh
 #!/bin/sh
-# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2006-2011 OpenWrt.org
 
 . /etc/functions.sh
 [ $# = 0 ] && { echo "  $0 <group>"; exit; }
 
 . /etc/functions.sh
 [ $# = 0 ] && { echo "  $0 <group>"; exit; }
-[ "x$1" = "x-a" ] && {
-       [ -e "/tmp/resolv.conf.auto" ] && rm /tmp/resolv.conf.auto
-       config_cb() {
-               [ interface != "$1" -o -z "$2" ] || eval "$0 $2"
-       }
-       config_load network
-       exit
-}
+
+case "$1" in
+       "-a")
+               [ -e "/tmp/resolv.conf.auto" ] && rm /tmp/resolv.conf.auto
+               config_cb() {
+                       [ interface != "$1" -o -z "$2" ] || eval "$0 -w $2"
+               }
+               config_load network
+               exit 0
+       ;;
+       "-w") shift ;;
+esac
 
 include /lib/network
 scan_interfaces
 
 include /lib/network
 scan_interfaces
index 6acd2ed09978276636c6a1a27f27453d67b701b5..5f8d80dc2ddf16319d22ceaf59d668f81b6f7658 100755 (executable)
@@ -5,14 +5,42 @@
 
 . /etc/functions.sh
 [ $# = 0 ] && { echo "  $0 <group>"; exit; }
 
 . /etc/functions.sh
 [ $# = 0 ] && { echo "  $0 <group>"; exit; }
-[ "x$1" = "x-a" ] && {
-       [ -e "/tmp/resolv.conf.auto" ] && rm /tmp/resolv.conf.auto
-       config_cb() {
-               [ interface != "$1" -o -z "$2" ] || eval "$0 $2"
+
+setup_wifi=1
+
+case "$1" in
+       "-a")
+               [ -e "/tmp/resolv.conf.auto" ] && rm /tmp/resolv.conf.auto
+               config_cb() {
+                       [ interface != "$1" -o -z "$2" ] || eval "$0 -w $2"
+               }
+               config_load network
+               exit 0
+       ;;
+       "-w") setup_wifi=0; shift ;;
+esac
+
+if [ $setup_wifi -gt 0 ] && grep -q config /etc/config/wireless; then
+       find_related_radios() {
+               local wdev wnet
+               config_get wdev "$1" device
+               config_get wnet "$1" network
+
+               if [ -n "$wdev" ] && [ "$wnet" = "$network" ]; then
+                       append radio_devs "$wdev" "$N"
+               fi
        }
        }
-       config_load network
-       exit
-}
+
+       local radio_devs
+       local network="$1"
+       config_load wireless
+       config_foreach find_related_radios wifi-iface
+
+       local dev
+       for dev in $(echo "$radio_devs" | sort -u); do
+               /sbin/wifi up "$dev"
+       done
+fi
 
 include /lib/network
 scan_interfaces
 
 include /lib/network
 scan_interfaces