finally move buildroot-ng to trunk
[openwrt/svn-archive/archive.git] / package / base-files / default / sbin / wifi
1 #!/bin/sh
2 # Copyright (C) 2006 OpenWrt.org
3
4 . /etc/functions.sh
5
6 config_get_bool() {
7 local _tmp
8 config_get "$1" "$2" "$3"
9 eval "_tmp=\$$1"
10 case "$_tmp" in
11 1|on|enabled) eval "$1=1";;
12 0|off|disabled) eval "$1=0";;
13 *) eval "$1=${4:-0}";;
14 esac
15 }
16
17 config_cb() {
18 config_get TYPE "$CONFIG_SECTION" TYPE
19 case "$TYPE" in
20 wifi-device)
21 append DEVICES "$CONFIG_SECTION"
22 ;;
23 wifi-iface)
24 config_get device "$CONFIG_SECTION" device
25 config_get vifs "$device" vifs
26 append vifs "$CONFIG_SECTION"
27 config_set "$device" vifs "$vifs"
28 ;;
29 esac
30 }
31
32 config_load wireless
33 include /lib/wifi
34
35 for device in $DEVICES; do (
36 config_get iftype "$device" type
37 eval "type setup_$iftype" 2>/dev/null >/dev/null && {
38 eval "scan_$iftype '$device'"
39 eval "setup_$iftype '$device'" && {
40 # TODO: set up network settings
41 /bin/true
42 } || echo "$device($iftype): Setup failed" || true
43 } || echo "$device($iftype): Interface type not supported"
44 ); done