netifd: reload the network config on ifup -a
[openwrt/openwrt.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 [[ "$1" == "-a" ]] && {
17 [ "$modes" = "down up" ] && ubus call network reload
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"