#!/bin/sh

. /lib/functions.sh

if [ "$(uci -q show network | grep omr6in4)" = "" ]; then
	uci -q batch <<-EOF >/dev/null
	set network.omr6in4=interface
	set network.omr6in4.proto=6in4
	set network.omr6in4.ip4table=vpn
	set network.omr6in4.multipath=off
	set network.omr6in4.ipaddr=10.255.255.2
	set network.omr6in4.peeraddr=10.255.255.1
	set network.omr6in4.gateway=fe80::a00:1
	set network.omr6in4.ip6addr='fe80::a00:2/128'
	set network.omr6in4.auto='0'
	commit network
	EOF
fi

if [ "$(uci -q get ucitrack.@network[-1].affects | grep omr6in4)" = "" ]; then
	uci -q batch <<-EOF >/dev/null
	add_list ucitrack.@network[-1].affects=omr6in4
	commit ucitrack
	EOF
fi


if [ "$(uci -q get network.omr6in4.ip6addr)" = "" ]; then
	uci -q batch <<-EOF >/dev/null
	set network.omr6in4.ip6addr=fe80::a00:2
	commit network
	EOF
fi

if [ "$(uci -q get firewall.zone_vpn.network | grep omr6in4)" = "" ]; then
	uci -q batch <<-EOF >/dev/null
	add_list firewall.zone_vpn.network=omr6in4
	commit firewall
	EOF
fi
rm -f /tmp/luci-indexcache
exit 0
