#!/bin/sh

uci -q batch <<-EOF > /dev/null
	delete ucitrack.@udp2raw[-1]
	add ucitrack udp2raw
	set ucitrack.@udp2raw[-1].init=udp2raw
	commit ucitrack
	delete firewall.udp2raw
	set firewall.udp2raw=include
	set firewall.udp2raw.type=script
	set firewall.udp2raw.path=/var/etc/udp2raw.include
	set firewall.udp2raw.reload=1
	commit firewall
EOF

general=$(uci -q get udp2raw.@general[-1])
if [ -z "$general" ]; then
	uci -q add udp2raw general
fi
if [ "$general"x != "general"x ]; then
	uci -q batch <<-EOF > /dev/null
		rename udp2raw.@general[-1]="general"
		set udp2raw.@general[-1].server="nil"
		commit udp2raw
	EOF
fi

rm -rf /tmp/luci-indexcache /tmp/luci-modulecache
exit 0
