1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-02-15 03:51:51 +00:00
openmptcprouter-feeds/openmptcprouter/files/etc/uci-defaults/1920-omr-network
2018-04-25 18:15:08 +02:00

117 lines
2.9 KiB
Bash
Executable file

#!/bin/sh
. /lib/functions.sh
_setup_macaddr() {
uci -q get "network.$1_dev.macaddr" >/dev/null && return
uci -q set "network.$1_dev.macaddr=$2"
}
_setup_macvlan() {
uci -q get "network.$1_dev.ifname" >/dev/null && return
# do not create macvlan for vlan
local _ifname
_ifname=$(uci -q get "network.$1.ifname")
case "$_ifname" in
eth*.*) return ;;
esac
uci -q batch <<-EOF
set network.$1_dev=device
set network.$1_dev.name=$1
set network.$1_dev.type=macvlan
set network.$1_dev.ifname=$_ifname
set network.$1.ifname=$1
EOF
_macaddr=$(uci -q get "network.$1.macaddr")
_setup_macaddr "$1" "${_macaddr:-auto$(date +%s)}"
uci -q set "network.$1.type=macvlan" # legacy
}
#uci -q set "network.lan.ip6assign=64"
if [ "$(uci -q show network | grep wan)" = "" ]; then
if [ -d /sys/class/net/eth1 ]; then
if [ -d /sys/class/net/eth2 ]; then
uci -q batch <<-EOF
set network.wan1=interface
set network.wan1.ifname=eth1
set network.wan1.proto=static
set network.wan1.ip4table=wan
set network.wan1.multipath=master
set network.wan1.defaultroute=0
commit network
add_list firewall.@zone[1].network=wan1
commit firewall
set network.wan2=interface
set network.wan2.ifname=eth2
set network.wan2.proto=static
set network.wan2.ip4table=wan
set network.wan2.multipath=on
set network.wan2.defaultroute=0
commit network
add_list firewall.@zone[1].network=wan2
commit firewall
EOF
else
uci -q batch <<-EOF
set network.wan1=interface
set network.wan1.ifname=eth1
set network.wan1.proto=static
set network.wan1.type=macvlan
set network.wan1.ip4table=wan
set network.wan1.multipath=master
set network.wan1.defaultroute=0
commit network
add_list firewall.@zone[1].network=wan1
commit firewall
set network.wan2=interface
set network.wan2.ifname=eth1
set network.wan2.proto=static
set network.wan2.type=macvlan
set network.wan2.ip4table=wan
set network.wan2.multipath=on
set network.wan2.defaultroute=0
commit network
add_list firewall.@zone[1].network=wan2
commit firewall
EOF
_setup_macvlan wan1
_setup_macvlan wan2
fi
else
uci -q batch <<-EOF
set network.wan1=interface
set network.wan1.ifname=eth0
set network.wan1.proto=static
set network.wan1.type=macvlan
set network.wan1.ip4table=wan
set network.wan1.multipath=master
set network.wan1.defaultroute=0
commit network
add_list firewall.@zone[1].network=wan1
commit firewall
set network.wan2=interface
set network.wan2.ifname=eth0
set network.wan2.proto=static
set network.wan2.type=macvlan
set network.wan2.ip4table=wan
set network.wan2.multipath=on
set network.wan2.defaultroute=0
commit network
add_list firewall.@zone[1].network=wan2
commit firewall
EOF
_setup_macvlan wan1
_setup_macvlan wan2
fi
uci -q batch <<-EOF
add network route6
set network.@route6[-1].interface='lan'
set network.@route6[-1].target='::/0'
commit network
EOF
rm -f /tmp/luci-indexcache
fi
exit 0