gluon-packages/gluon/gluon-core/files/lib/gluon/upgrade/core/initial/011-gluon-network

63 lines
1.4 KiB
Bash
Executable File

#!/bin/sh
. /lib/ar71xx.sh
local lan_ifname="$(uci get network.lan.ifname)"
local board="$(ar71xx_board_name)"
uci -q batch <<EOF
delete network.lan
set network.wan.type='bridge'
set network.wan.proto='dhcp'
set network.wan.auto='1'
set network.client='interface'
set network.client.ifname='$lan_ifname bat0'
set network.client.type='bridge'
set network.client.proto='none'
set network.client.auto='1'
set network.mesh='interface'
set network.mesh.proto='batadv'
set network.mesh.mtu='1528'
set network.mesh.mesh='bat0'
set network.mesh_vpn='interface'
set network.mesh_vpn.ifname='mesh-vpn'
set network.mesh_vpn.proto='batadv'
set network.mesh_vpn.mesh='bat0'
EOF
get_main_address() {
case "$board" in
tl-wdr3600|tl-wdr4300)
cat /sys/class/ieee80211/phy1/macaddress
;;
*)
cat /sys/class/ieee80211/phy0/macaddress
;;
esac
}
local mainaddr=$(get_main_address)
local oIFS="$IFS"; IFS=":"; set -- $mainaddr; IFS="$oIFS"
local b2mask=0x02
local vpnaddr=$(printf "%02x:%s:%s:%02x:%s:%s" $(( 0x$1 | $b2mask )) $2 $3 $(( (0x$4 + 1) % 0x100 )) $5 $6)
uci set network.client.macaddr="$mainaddr"
uci set network.mesh_vpn.macaddr="$vpnaddr"
case "$board" in
tl-wr1043nd|\
tl-wdr3600|\
tl-wdr4300) # fix up duplicate mac addresses
local wanaddr=$(printf "%02x:%s:%s:%02x:%s:%02x" $(( 0x$1 | $b2mask )) $2 $3 $(( (0x$4 + 1) % 0x100 )) $5 $(( (0x$6 + 1) % 0x100 )) )
uci set network.wan.macaddr="$wanaddr"
;;
esac
uci commit network