#!/bin/sh /etc/rc.common 
get_info() {
	include /lib/network
	scan_interfaces
	config_get lanip lan ipaddr
	config_get lanmask lan netmask

	REDIR="-s ${lanip:-192.168.10.1}/${lanmask:-255.255.255.0} -d ! ${lanip:-192.168.10.1}/${lanmask:-255.255.255.0} -p tcp --dport 80 -j REDIRECT --to-ports 8080"
}

start() {
		get_info

		iptables -A INPUT_CFG -j ACCEPT
		iptables -t nat -I PREROUTING 1 $REDIR
		
		# Start the splash page redirect
		/usr/sbin/httpd -R /cgi-bin/webif/splash.sh -H "$lanip" -p 8080 -h /www -r OpenWrt
}

stop() {
		export HOTSPOT=1
		/etc/init.d/dnsmasq restart &

		get_info
		iptables -F INPUT_CFG
		iptables -t nat -D PREROUTING $REDIR
}
