1 # setup entry in /etc/config/network for a interface
2 # Argument $1: network interface
8 # Setup a (new) interface section for $net
10 ipaddr=$(uci get meshwizard.netconfig.$net\_ip4addr)
11 [ -z "$ipaddr" ] && msg_missing_value meshwizard $net\_ip4addr
12 [ -z "$interface_netmask" ] && interface netmask="255.255.0.0"
15 set network.$netrenamed="interface"
16 set network.$netrenamed.proto="static"
17 set network.$netrenamed.ipaddr="$ipaddr"
19 set_defaults "interface_" network.$netrenamed
20 uci_commitverbose "Setup interface $netrenamed" network
22 # setup dhcp alias/interface
24 net_dhcp=$(uci -q get meshwizard.netconfig.${net}_dhcp)
25 if [ "$net_dhcp" == 1 ]; then
27 # Load meshwizard_settings
28 dhcprange="$(uci -q get meshwizard.netconfig.${net}_dhcprange)"
29 interface_ip="$(uci -q get meshwizard.netconfig.${net}_ip4addr)"
30 vap=$(uci -q get meshwizard.netconfig.${net}_vap)
34 config_get interface "$1" interface
35 if [ "$interface" == "$netrenamed" ]; then
36 if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then
37 section_rename network $1 ${netrenamed}dhcp
42 config_foreach handle_dhcpalias alias
44 # Get IP/netmask and start-ip for $net dhcp
45 # If no dhcprange is given in /etc/config/meshwizard we autogenerate one
47 if [ -z "$dhcprange" ]; then
48 dhcprange="$($dir/helpers/gen_dhcp_ip.sh $interface_ip)/24"
49 uci set meshwizard.netconfig.${net}_dhcprange="$dhcprange"
51 eval $(sh $dir/helpers/ipcalc-cidr.sh $dhcprange 1 0)
53 # setup wifi-dhcp interface or alias
55 # Setup alias for $net
57 if [ "$vap" == 1 ]; then
58 uci set network.${netrenamed}dhcp=interface
60 uci set network.${netrenamed}dhcp=alias
61 uci set network.${netrenamed}dhcp.interface="$netrenamed"
65 set network.${netrenamed}dhcp.proto=static
66 set network.${netrenamed}dhcp.ipaddr="$START"
67 set network.${netrenamed}dhcp.netmask="$NETMASK"
68 uci_commitverbose "Setup interface for ${netrenamed}dhcp" network