#!/bin/sh
[ ! -f "/usr/share/ucitrack/luci-app-mnh.json" ] && {
    cat > /usr/share/ucitrack/luci-app-mnh.json << EEOF
{
    "config": "mnh",
    "init": "mnh"
}
EEOF
}

uci -q batch <<-EOF >/dev/null
	delete ucitrack.@mnh[-1]
	add ucitrack mnh
	set ucitrack.@mnh[-1].init=mnh
	commit ucitrack
EOF

if fw4 >/dev/null; then
	uci -q batch <<-EOF
		delete firewall.mnh
		set firewall.mnh=include
		set firewall.mnh.type=script
		set firewall.mnh.path=/usr/share/mnh/firewall4.include
		commit firewall
	EOF
else
	uci -q batch <<-EOF
		delete firewall.mnh
		set firewall.mnh=include
		set firewall.mnh.type=script
		set firewall.mnh.path=/usr/share/mnh/firewall3.include
		set firewall.mnh.family=ipv4
		set firewall.mnh.reload=1
		commit firewall
	EOF
fi

exit 0