010-freifunk-migrate-batman-adv 809 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/bin/sh
  2. . /lib/ar71xx.sh
  3. local board="$(ar71xx_board_name)"
  4. uci -q batch <<EOF
  5. set network.mesh.proto='batadv'
  6. set network.mesh.mesh='bat0'
  7. set network.mesh_vpn='interface'
  8. set network.mesh_vpn.ifname='mesh-vpn'
  9. set network.mesh_vpn.proto='batadv'
  10. set network.mesh_vpn.mesh='bat0'
  11. EOF
  12. get_main_address() {
  13. case "$board" in
  14. tl-wdr3600|tl-wdr4300)
  15. uci get wireless.radio1.macaddr
  16. ;;
  17. *)
  18. uci get wireless.radio0.macaddr
  19. ;;
  20. esac
  21. }
  22. local mainaddr=$(get_main_address)
  23. local oIFS="$IFS"; IFS=":"; set -- $mainaddr; IFS="$oIFS"
  24. local b2mask=0x02
  25. local vpnaddr=$(printf "%02x:%s:%s:%02x:%s:%s" $(( 0x$1 | $b2mask )) $2 $3 $(( (0x$4 + 1) % 0x100 )) $5 $6)
  26. uci set network.mesh_vpn.macaddr="$vpnaddr"
  27. uci commit network
  28. uci delete batman-adv.bat0.interfaces
  29. uci commit batman-adv