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
13 netmask
=$
(uci
-q get meshwizard.netconfig.
$net\_netmask
)
14 [ -z "$netmask" ] && netmask
="$interface_netmask"
15 [ -z "$netmask" ] && netmask
="255.255.0.0"
17 uci
set network.
$netrenamed="interface"
18 set_defaults
"interface_" network.
$netrenamed
21 set network.$netrenamed.proto="static"
22 set network.$netrenamed.ipaddr="$ipaddr"
23 set network.$netrenamed.netmask="$netmask"
26 uci_commitverbose
"Setup interface $netrenamed" network
28 # setup dhcp alias/interface
30 net_dhcp
=$
(uci
-q get meshwizard.netconfig.
${net}_dhcp
)
31 if [ "$net_dhcp" == 1 ]; then
33 # Load meshwizard_settings
34 dhcprange
="$(uci -q get meshwizard.netconfig.${net}_dhcprange)"
35 interface_ip
="$(uci -q get meshwizard.netconfig.${net}_ip4addr)"
36 vap
=$
(uci
-q get meshwizard.netconfig.
${net}_vap
)
40 config_get interface
"$1" interface
41 if [ "$interface" == "$netrenamed" ]; then
42 if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then
43 section_rename network
$1 ${netrenamed}dhcp
48 config_foreach handle_dhcpalias
alias
50 # Get IP/netmask and start-ip for $net dhcp
51 # If no dhcprange is given in /etc/config/meshwizard we autogenerate one
53 if [ -z "$dhcprange" ]; then
54 dhcprange
="$($dir/helpers/gen_dhcp_ip.sh $interface_ip)/24"
55 uci
set meshwizard.netconfig.
${net}_dhcprange
="$dhcprange"
57 eval $
(sh
$dir/helpers
/ipcalc-cidr.sh
$dhcprange 1 0)
59 # setup wifi-dhcp interface or alias
61 # Setup alias for $net
63 if [ "$vap" == 1 ]; then
64 uci
set network.
${netrenamed}dhcp
=interface
66 uci
set network.
${netrenamed}dhcp
=alias
67 uci
set network.
${netrenamed}dhcp.interface
="$netrenamed"
71 set network.${netrenamed}dhcp.proto=static
72 set network.${netrenamed}dhcp.ipaddr="$START"
73 set network.${netrenamed}dhcp.netmask="$NETMASK"
75 uci_commitverbose
"Setup interface for ${netrenamed}dhcp" network