X-Git-Url: https://git.rohieb.name/openwrt.git/blobdiff_plain/ed5ef674d100ca0ffa8bc00160718f69af5515c3..c5a86e2fbb0372968a597a395ea90cc26f8a1fcf:/package/base-files/default/sbin/wifi diff --git a/package/base-files/default/sbin/wifi b/package/base-files/default/sbin/wifi index 63b2f121b..67ccb8a0b 100755 --- a/package/base-files/default/sbin/wifi +++ b/package/base-files/default/sbin/wifi @@ -3,6 +3,49 @@ . /etc/functions.sh +wifi_up() { + for device in ${2:-$DEVICES}; do ( + config_get iftype "$device" type + if eval "type enable_$iftype" 2>/dev/null >/dev/null; then + eval "scan_$iftype '$device'" + eval "enable_$iftype '$device'" || echo "$device($iftype): Setup failed" + else + echo "$device($iftype): Interface type not supported" + fi + ); done +} + +wifi_down() { + for device in ${2:-$DEVICES}; do ( + config_get iftype "$device" type + if eval "type disable_$iftype" 2>/dev/null >/dev/null; then + eval "scan_$iftype '$device'" + eval "disable_$iftype '$device'" || echo "$device($iftype): Disable failed" + else + echo "$device($iftype): Interface type not supported" + fi + ); done +} + +wifi_detect() { + for driver in ${2:-$DRIVERS}; do ( + if eval "type detect_$driver" 2>/dev/null >/dev/null; then + eval "detect_$driver" || echo "$driver: Detect failed" >&2 + else + echo "$driver: Hardware detection not supported" >&2 + fi + ); done +} + +start_net() {( + local iface="$1" + local config="$2" + + include /lib/network + scan_interfaces + setup_interface "$1" "$2" +)} + config_get_bool() { local _tmp config_get "$1" "$2" "$3" @@ -29,21 +72,13 @@ config_cb() { esac } +DEVICES= +DRIVERS= config_load wireless +include /lib/wifi -[ -d /lib/wifi -a -n "$(ls /lib/wifi/*.sh 2>&-)" ] && { - for script in /lib/wifi/*.sh; do - . $script - done -} - -for device in $DEVICES; do ( - config_get type "$device" type - eval "type setup_$type" 2>/dev/null >/dev/null && { - eval "scan_$type '$device'" - eval "setup_$type '$device'" && { - # TODO: set up network settings - /bin/true - } || echo "$device($type): Setup failed" || true - } || echo "$device($type): Interface type not supported" -); done +case "$1" in + down) wifi_down "$2";; + detect) wifi_detect "$2";; + *) wifi_up "$2";; +esac