[package] netifd: port r27720 (#9763) to the netifd ifup variant
[openwrt/svn-archive/archive.git] / package / netifd / files / sbin / ifup
1 #!/bin/sh
2
3 case "$0" in
4 *ifdown) modes=down;;
5 *ifup) modes="down up";;
6 *) echo "Invalid command: $0";;
7 esac
8
9 if_call() {
10 local interface="$1"
11 for mode in $modes; do
12 ubus call $interface $mode
13 done
14 }
15
16 [ "$modes" = "down up" ] && ubus call network reload
17 [[ "$1" == "-a" ]] && {
18 for interface in `ubus -S list 'network.interface.*'`; do
19 if_call "$interface"
20 done
21 exit
22 }
23
24 ubus -S list "network.interface.$1" > /dev/null || {
25 echo "Interface $1 not found"
26 exit
27 }
28 if_call "network.interface.$1"
29
30 grep -sq ^config /etc/config/wireless && {
31 local wdev
32 for wdev in $(
33 find_radio() {
34 local wdev wnet
35 config_get wdev "$1" device
36 config_get wnet "$1" network
37 [ -n "$wdev" ] && [ "$wnet" = "$2" ] && echo "$wdev"
38 }
39
40 source /lib/functions.sh
41 config_load wireless
42 config_foreach find_radio wifi-iface "$1" | sort -u
43 ); do
44 /sbin/wifi up "$wdev"
45 done
46 }