# Set Time
uci set system.@system[0].zonename='America/New York'
uci set system.@system[0].timezone='EST5EDT,M3.2.0,M11.1.0'
uci commit system

# Common Settings between three modes
# Network Settings
uci set network.loopback=interface
uci set network.loopback.ifname="lo"
uci set network.loopback.proto="static"
uci set network.loopback.ipaddr="127.0.0.1"
uci set network.loopback.netmask="255.0.0.0"
uci set network.globals=globals
uci set network.globals.ula_prefix="fd18:0640:804c::/48"
uci set network.globals.packet_steering='1'

# Setup networking defaults based on mode
case "${SHIELD_MODE}" in
	"Router" | "Gateway")
		# Network Setup
		uci set network.wan=interface
		uci set network.wan.ifname='eth0'
		uci set network.wan.proto='dhcp'

		uci set network.lan=interface
		uci set network.lan.ifname='eth1 eth2'
		uci set network.lan.force_link='1'
		uci set network.lan.proto='static'
		uci set network.lan.type='bridge'
		uci set network.lan.ipaddr='10.10.10.10'
		uci set network.lan.netmask='255.255.255.0'
		uci set network.lan.ip6assign='60'

		uci set network.wan6=interface
		uci set network.wan6.ifname='eth0'
		uci set network.wan6.proto='dhcpv6'
		uci commit network

                # DHCP/DNS Setup
		uci set dhcp.@dnsmasq[0]=dnsmasq
		uci set dhcp.@dnsmasq[0].domainneeded='1'
		uci set dhcp.@dnsmasq[0].localise_queries='1'
		uci set dhcp.@dnsmasq[0].rebind_protection='1'
		uci set dhcp.@dnsmasq[0].rebind_localhost='1'
		uci set dhcp.@dnsmasq[0].local='/lan/'
		uci set dhcp.@dnsmasq[0].domain='lan'
		uci set dhcp.@dnsmasq[0].expandhosts='1'
		uci set dhcp.@dnsmasq[0].authoritative='1'
		uci set dhcp.@dnsmasq[0].readethers='1'
		uci set dhcp.@dnsmasq[0].leasefile='/tmp/dhcp.leases'
		uci set dhcp.@dnsmasq[0].localservice='1'
		uci set dhcp.@dnsmasq[0].resolvfile='/tmp/resolv.conf.auto'
		uci set dhcp.@dnsmasq[0].confdir='/tmp/dnsmasq.d'
		uci set dhcp.@dnsmasq[0].server='1.1.1.1'
		uci set dhcp.@dnsmasq[0].port='53'

		uci set dhcp.lan=dhcp
		uci set dhcp.lan.interface='lan'
		uci set dhcp.lan.start='100'
		uci set dhcp.lan.limit='150'
		uci set dhcp.lan.leasetime='12h'
		uci set dhcp.lan.dhcpv6='server'
		uci set dhcp.lan.ra='server'
		uci set dhcp.lan.ra_slaac='1'
		uci set dhcp.lan.ra_management='1'
		uci set dhcp.lan.forced_link='1'

		uci set dhcp.wan=dhcp
		uci set dhcp.wan.interface='wan'
		uci set dhcp.wan.ignore='1'

		uci set dhcp.odhcpd=odhcpd
		uci set dhcp.odhcpd.maindhcp='0'
		uci set dhcp.odhcpd.leasefile='/tmp/hosts/odhcpd'
		uci set dhcp.odhcpd.leasetrigger='/usr/sbin/odhcpd-update'
		uci set dhcp.odhcpd.loglevel='4'
		uci commit dhcp


		# Adblock Setup
		uci set adblock.global=adblock
		uci set adblock.global.adb_enabled='1'
		uci set adblock.global.adb_forcedns='0'
		uci set adblock.global.adb_safesearch='0'
		uci set adblock.global.adb_mail='0'
		uci set adblock.global.adb_maxqueue='4'
		uci set adblock.global.adb_dns='dnsmasq'
		uci set adblock.global.adb_trigger='wan'
		uci set adblock.global.adb_report='1'
		uci set adblock.global.adb_repiface='br-lan'
		uci set adblock.global.adb_dnsfilereset='1'
		uci set adblock.global.adb_dnsflush='1'
		uci add_list adblock.global.adb_sources='oisd_nl'
		uci add_list adblock.global.adb_sources='youtube'
		uci set adblock.global.adb_fetchutil='uclient-fetch'
		uci set adblock.global.adb_debug='1'
		uci set adblock.global.adb_backup='1'
		uci set adblock.global.adb_backupdir='/etc/adblock'
		uci set adblock.global.adb_forcedns='1'

		uci commit adblock

		# uhttpd Setup
		uci set uhttpd.main=uhttpd
		uci set uhttpd.main.listen_http='10.10.10.10:80'
		uci set uhttpd.main.listen_https='10.10.10.10:443'
		uci set uhttpd.main.redirect_https='1'
		uci set uhttpd.main.home='/www'
		uci set uhttpd.main.rfc1918_filter='1'
		uci set uhttpd.main.max_requests='3'
		uci set uhttpd.main.max_connections='100'
		uci set uhttpd.main.cert='/etc/uhttpd.crt'
		uci set uhttpd.main.key='/etc/uhttpd.key'
		uci set uhttpd.main.cgi_prefix='/cgi-bin'
		uci set uhttpd.main.lua_prefix='/cgi-bin/luci=/usr/lib/lua/luci/sgi/uhttpd.lua'
		uci set uhttpd.main.script_timeout='60'
		uci set uhttpd.main.network_timeout='30'
		uci set uhttpd.main.http_keepalive='20'
		uci set uhttpd.main.tcp_keepalive='1'
		uci set uhttpd.main.ubus_prefix='/ubus'
		uci set uhttpd.defaults=cert
		uci set uhttpd.defaults.days='730'
		uci set uhttpd.defaults.bits='2048'
		uci set uhttpd.defaults.country='ZZ'
		uci set uhttpd.defaults.state='Somewhere'
		uci set uhttpd.defaults.location='Unknown'
		uci set uhttpd.defaults.commonname='OpenWrt'

		# Snort++ Settings
		uci set snort.snort.interface='eth0:br-lan'
		uci set snort.snort.alert_module='alert_full'
		uci set snort.snort.config_dir='/etc/snort'
		uci set snort.snort.daq='afpacket'
		uci set snort.snort.daq_dir='/usr/lib/daq'
		uci set snort.snort.log_dir='/tmp/'
	;;
	"Bridge")
	;;
esac
