1 # setup entry in /etc/config/network for a interface
2 # Argument $1: network interface
8 # Delete the network interface section for $net
9 if [ "$cleanup" == 1 ]; then
10 section_cleanup network.$netrenamed
13 # Setup a (new) interface section for $net
15 ipaddr=$(uci get meshwizard.netconfig.$net\_ip4addr)
16 [ -z "$ipaddr" ] && msg_missing_value meshwizard $net\_ip4addr
17 [ -z "$interface_netmask" ] && interface netmask="255.255.0.0"
20 set network.$netrenamed="interface"
21 set network.$netrenamed.proto="static"
22 set network.$netrenamed.ipaddr="$ipaddr"
23 set network.$netrenamed.netmask="$interface_netmask"
24 set network.$netrenamed.dns="$interface_dns"
27 uci_commitverbose "Setup interface $netrenamed" network
29 # setup dhcp alias/interface
31 net_dhcp=$(uci -q get meshwizard.netconfig.${net}_dhcp)
32 if [ "$net_dhcp" == 1 ]; then
34 # Load meshwizard_settings
35 dhcprange="$(uci -q get meshwizard.netconfig.${net}_dhcprange)"
36 interface_ip="$(uci -q get meshwizard.netconfig.${net}_ip4addr)"
37 vap=$(uci -q get meshwizard.netconfig.${net}_vap)
41 config_get interface "$1" interface
42 if [ "$interface" == "$netrenamed" ]; then
43 if [ "$cleanup" == 1 ]; then
44 section_cleanup network.$1
46 if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then
47 section_rename network $1 ${netrenamed}dhcp
53 config_foreach handle_dhcpalias alias
55 # Get IP/netmask and start-ip for $net dhcp
56 # If no dhcprange is given in /etc/config/meshwizard we autogenerate one
58 if [ -z "$dhcprange" ]; then
59 dhcprange="$($dir/helpers/gen_dhcp_ip.sh $interface_ip)/24"
60 uci set meshwizard.netconfig.${net}_dhcprange="$dhcprange"
62 eval $(sh $dir/helpers/ipcalc-cidr.sh $dhcprange 1 0)
64 # setup wifi-dhcp interface or alias
66 # Setup alias for $net
68 if [ "$vap" == 1 ]; then
69 uci set network.${netrenamed}dhcp=interface
71 uci set network.${netrenamed}dhcp=alias
72 uci set network.${netrenamed}dhcp.interface="$netrenamed"
76 set network.${netrenamed}dhcp.proto=static
77 set network.${netrenamed}dhcp.ipaddr="$START"
78 set network.${netrenamed}dhcp.netmask="$NETMASK"
83 uci_commitverbose "Setup interface for ${netrenamed}dhcp" network