#!/bin/sh

uci -q batch <<-EOF >/dev/null
	set dhcp.@dnsmasq[0].localuse=1
	commit dhcp
	delete ucitrack.@passwall2[-1]
	add ucitrack passwall2
	set ucitrack.@passwall2[-1].init=passwall2
	commit ucitrack
	delete firewall.passwall2
	set firewall.passwall2=include
	set firewall.passwall2.type=script
	set firewall.passwall2.path=/var/etc/passwall2.include
	set firewall.passwall2.reload=1
	commit firewall
	delete ucitrack.@passwall2_server[-1]
	add ucitrack passwall2_server
	set ucitrack.@passwall2_server[-1].init=passwall2_server
	commit ucitrack
	delete firewall.passwall2_server
	set firewall.passwall2_server=include
	set firewall.passwall2_server.type=script
	set firewall.passwall2_server.path=/var/etc/passwall2_server.include
	set firewall.passwall2_server.reload=1
	commit firewall
	set uhttpd.main.max_requests=50
	commit uhttpd
EOF

[ ! -s "/etc/config/passwall2" ] && cp -f /usr/share/passwall2/0_default_config /etc/config/passwall2
touch /etc/config/passwall2_show >/dev/null 2>&1
rm -f /tmp/luci-indexcache
rm -rf /tmp/luci-modulecache/
killall -HUP rpcd 2>/dev/null
exit 0
