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-02-15 14:19:47 +01:00

59 lines
1.4 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=eth0
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
}
if [ "$(uci -q show network | grep wan)" = "" ]; then
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
rm -f /tmp/luci-indexcache
fi
exit 0