Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Adblock for Buffalo WHR-G54
#!/bin/sh
logger WAN up script executing
sleep 2
logger Create Whitelist
if test ! -s /tmp/whitelist
then
cat >/tmp/whitelist <<"EOF"
ads.hulu.com
track.hulu.com
ads-v-darwin.hulu.com
ll.a.hulu.com
a.huluad.com
hulu.112.2o7.net
huludev.112.2o7.net
EOF
fi
if test ! -s /tmp/dlhosts
then
cat >/tmp/dlhosts <<"EOF"
logger Downloading http://www.mvps.org/winhelp2002/hosts.txt
wget -q -O - http://www.mvps.org/winhelp2002/hosts.txt | grep -v localhost | tr -d '\015' > /tmp/hosts0
pixel="`ifconfig br0 | grep inet | awk '{ print $3 }' | awk -F ":" '{ print $2 }' | cut -c 1-10`"254
cat /tmp/whitelist | while read line; do sed -i /${line}/d /tmp/hosts0 ; done
sed -i s/0.0.0.0/$pixel/g /tmp/hosts0
grep addn-hosts /tmp/dnsmasq.conf ||
echo "addn-hosts=/tmp/hosts0" >>/tmp/dnsmasq.conf
logger Restarting dnsmasq
killall dnsmasq
dnsmasq --conf-file=/tmp/dnsmasq.conf
EOF
chmod 777 /tmp/dlhosts
/tmp/dlhosts
fi
logger Free Port 80
killall httpd
cd /www
httpd -p 81 -h /www
logger "Redirect setup & Appending to the FW script"
[[ -z "`iptables -L -n -t nat | grep $(nvram get lan_ipaddr) | grep 81`" ]] && logger "did NOT find an active redirect rule with the iptable command, injecting it now." && /usr/sbin/iptables -t nat -I PREROUTING 1 -d $(nvram get lan_ipaddr) -p tcp --dport 80 -j DNAT --to $(nvram get lan_ipaddr):81
nvram get rc_firewall > /tmp/fw.tmp
if [[ -z "`cat /tmp/fw.tmp | grep "/usr/sbin/iptables -t nat -I PREROUTING 1 -d $(nvram get lan_ipaddr) -p tcp --dport 80 -j DNAT --to $(nvram get lan_ipaddr):81"`" ]] ; then
echo "/usr/sbin/iptables -t nat -I PREROUTING 1 -d $(nvram get lan_ipaddr) -p tcp --dport 80 -j DNAT --to $(nvram get lan_ipaddr):81" >> /tmp/fw.tmp
nvram set rc_firewall="`cat /tmp/fw.tmp`"
logger "DONE appending to FW script"
nvram set aviad_changed_nvram=1
else
logger "The FW script is already in place"
fi
rm /tmp/fw.tmp
logger Launch PixelServ
wget -q -O - http://pjdecarlo.com/pixelserv/pixelserv.c > /tmp/pixelserv
killall pixelserv
chmod 777 /tmp/pixelserv
pixel="`ifconfig br0 | grep inet | awk '{ print $3 }' | awk -F ":" '{ print $2 }' | cut -c 1-10`"254
/sbin/ifconfig br0:1 $pixel netmask "`ifconfig br0 | grep inet | awk '{ print $4 }' | awk -F ":" '{ print $2 }'`" broadcast "`ifconfig br0 | grep inet | awk '{ print $3 }' | awk -F ":" '{ print $2 }'`" up
/tmp/pixelserv $pixel
logger set up cron job
grep -q '/tmp/dlhosts' /tmp/crontab ||
echo "45 23 * * 5 root /tmp/dlhosts" >>/tmp/crontab
@toolboc

This comment has been minimized.

Copy link
Owner Author

@toolboc toolboc commented Dec 3, 2014

Add the following if you want to use Chilispot to set up a Wi-Fi access portal

sleep 30

Chilispot fails to add eth1 to br0 even though defined in settings

brctl addif br0 eth1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.