12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- #!/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.accept_ra='0'
- set network.wan.auto='1'
- set network.freifunk='interface'
- set network.freifunk.ifname='$lan_ifname bat0'
- set network.freifunk.type='bridge'
- set network.freifunk.proto='none'
- set network.freifunk.auto='1'
- set network.freifunk.accept_ra='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)
- uci get wireless.radio1.macaddr
- ;;
- *)
- uci get wireless.radio0.macaddr
- ;;
- 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.freifunk.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
|