#!/bin/sh

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

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