2011-06-20 21:11:00 +12:00
#!/bin/bash
#
2012-03-18 15:07:43 +13:00
# Fanboy Regional Tracking Combination script v1.4 (18/03/2012)
2011-06-20 21:11:00 +12:00
# Dual License CCby3.0/GPLv2
# http://creativecommons.org/licenses/by/3.0/
# http://www.gnu.org/licenses/gpl-2.0.html
#
2012-08-23 00:07:17 +12:00
export ZIP = "nice -n 19 /usr/local/bin/7za a -mx=9 -y -tgzip"
export NICE = "nice -n 19"
export TAC = "/usr/bin/tac"
export CAT = "/bin/cat"
2013-02-17 09:08:41 +13:00
export MAINDIR = "/var/www/adblock"
export SPLITDIR = "/var/www/adblock/split/test"
export HGSERV = "/root/fanboy-adblock-list"
2012-08-23 00:07:17 +12:00
export TESTDIR = "/tmp/work"
export ADDCHECKSUM = " nice -n 19 perl $HGSERV /scripts/addChecksum.pl "
export LOGFILE = "/etc/crons/log.txt"
export HG = "/usr/local/bin/hg"
export SHA256SUM = "/usr/bin/sha256sum"
2013-02-17 09:08:41 +13:00
export IEDIR = "/root/tmp/ieramdisk"
export SUBS = "/root/tmp/ieramdisk/subscriptions"
2012-03-11 15:33:01 +13:00
2011-06-20 21:11:00 +12:00
# Copy the Tracking addon from google dir
#
2012-08-23 19:01:41 +12:00
cp -f $HGSERV /other/tracking-intl.txt $TESTDIR
2011-06-20 21:11:00 +12:00
2012-08-23 19:01:41 +12:00
sed '1,10d' $HGSERV /ie/fanboy-tracking-addon.txt > $TESTDIR /fanboy-tracking-addon2.txt
2011-06-20 21:11:00 +12:00
mv -f $TESTDIR /fanboy-tracking-addon2.txt $TESTDIR /fanboy-tracking-addon.txt
# Copy Filters from the subscriptions..
#
2012-08-23 19:01:41 +12:00
sed -n '/Czech Trackers/,/Slovak Filters/{/Slovak Filters/!p}' $HGSERV /firefox-regional/fanboy-adblocklist-cz.txt > $TESTDIR /fanboy-cz-track.txt
sed -n '/Russian Trackers/,/Russian Whitelist/{/Russian Whitelist/!p}' $HGSERV /firefox-regional/fanboy-adblocklist-rus-v2.txt > $TESTDIR /fanboy-rus-track.txt
sed -n '/Turkish Trackers/,/Firefox 3.x/{/Firefox 3.x/!p}' $HGSERV /firefox-regional/fanboy-adblocklist-tky.txt > $TESTDIR /fanboy-tky-track.txt
sed -n '/Japanese Trackers/,/Japanese Whitelist/{/Japanese Whitelist/!p}' $HGSERV /firefox-regional/fanboy-adblocklist-jpn.txt > $TESTDIR /fanboy-jpn-track.txt
sed -n '/Korean Trackers/,/Korean Specific Whitelists/{/Korean Specific Whitelists/!p}' $HGSERV /firefox-regional/fanboy-adblocklist-krn.txt > $TESTDIR /fanboy-krn-track.txt
sed -n '/Italian Trackers/,/Whitelists/{/Whitelists/!p}' $HGSERV /firefox-regional/fanboy-adblocklist-ita.txt> $TESTDIR /fanboy-ita-track.txt
sed -n '/Polish Trackers/,/Polish Whitelist/{/Polish Whitelist/!p}' $HGSERV /firefox-regional/fanboy-adblocklist-pol.txt > $TESTDIR /fanboy-pol-track.txt
sed -n '/Indian Trackers/,/Indian Whitelists/{/Indian Whitelists/!p}' $HGSERV /firefox-regional/fanboy-adblocklist-ind.txt > $TESTDIR /fanboy-ind-track.txt
sed -n '/Vietnamese Trackers/,/Whitelists/{/Whitelists/!p}' $HGSERV /firefox-regional/fanboy-adblocklist-vtn.txt > $TESTDIR /fanboy-vtn-track.txt
sed -n '/Chinese Trackers/,/Chinese Whitelist/{/Chinese Whitelist/!p}' $HGSERV /firefox-regional/fanboy-adblocklist-chn.txt > $TESTDIR /fanboy-chn-track.txt
sed -n '/Portuguese Trackers/,/Portuguese Generic/{/Portuguese Generic/!p}' $HGSERV /firefox-regional/fanboy-adblocklist-esp.txt > $TESTDIR /fanboy-esp-track.txt
sed -n '/Swedish Trackers/,/Swedish Whitelist/{/Swedish Whitelist/!p}' $HGSERV /firefox-regional/fanboy-adblocklist-swe.txt > $TESTDIR /fanboy-swe-track.txt
2011-06-20 21:11:00 +12:00
2012-02-11 23:32:41 +13:00
# Remove Dubes and bad filters
#
sed -i '/\/stats.php/d' $TESTDIR /fanboy-ind-track.txt
sed -i '/c.waplog.net/d' $TESTDIR /fanboy-ind-track.txt
sed -i '/stat24.com/d' $TESTDIR /fanboy-pol-track.txt
sed -i '/stat.4u.pl/d' $TESTDIR /fanboy-cz-track.txt
sed -i '/publicidees.com/d' $TESTDIR /fanboy-ita-track.txt
sed -i '/hbxmodify/d' $TESTDIR /fanboy-krn-track.txt
sed -i '/urchin.js/d' $TESTDIR /fanboy-jpn-track.txt
sed -i '/topshoptv.com.ua/d' $TESTDIR /fanboy-rus-track.txt
sed -i '/stats.e-go.gr/d' $TESTDIR /fanboy-rus-track.txt
sed -i '/nigma.ru/d' $TESTDIR /fanboy-rus-track.txt
sed -i '/gemius_/d' $TESTDIR /fanboy-rus-track.txt
2012-05-28 20:44:06 +12:00
#
#
sed -i '/||cnzz.com/stat/d' $TESTDIR /fanboy-chn-track.txt
sed -i '/\/webtrekk./d' $TESTDIR /fanboy-ita-track.txt
sed -i '/.cn\/urchin.js/d' $TESTDIR /fanboy-chn-track.txt
sed -i '/||zoosnet.net/d' $TESTDIR /fanboy-chn-track.txt
sed -i '/||stat.tudou.com/d' $TESTDIR /fanboy-chn-track.txt
sed -i '/||bugun.com.tr\^\*\/stat.aspx/d' $TESTDIR /fanboy-tky-track.txt
sed -i '/||dot.wp.pl/d' $TESTDIR /fanboy-pol-track.txt
sed -i '/.com\/logger\//d' $TESTDIR /fanboy-krn-track.txt
sed -i '/||mc.yandex.ru/d' $TESTDIR /fanboy-rus-track.txt
sed -i '/||hotlog.ru/d' $TESTDIR /fanboy-rus-track.txt
sed -i '/||rek.www.wp.pl/d' $TESTDIR /fanboy-pol-track.txt
sed -i '/||spylog.ru\/counter/d' $TESTDIR /fanboy-rus-track.txt
sed -i '/||videoplaza.com\/proxy\/tracker/d' $TESTDIR /fanboy-swe-track.txt
sed -i '/||easyresearch.se/d' $TESTDIR /fanboy-swe-track.txt
sed -i '/||webiqonline.com/d' $TESTDIR /fanboy-krn-track.txt
sed -i '/||tns-counter.ru/d' $TESTDIR /fanboy-rus-track.txt
sed -i '/||newstogram/d' $TESTDIR /fanboy-esp-track.txt
sed -i '/||net-filter.com/d' $TESTDIR /fanboy-ind-track.txt
sed -i '/||openstat.net/d' $TESTDIR /fanboy-rus-track.txt
sed -i '/||post.rmbn.ru/d' $TESTDIR /fanboy-rus-track.txt
sed -i '/||waplog.net/d' $TESTDIR /fanboy-rus-track.txt
2012-02-11 23:32:41 +13:00
2011-06-20 21:11:00 +12:00
# Merge Everything together
#
2012-02-12 17:17:23 +13:00
# Merge for IE trackers
2012-03-11 15:13:37 +13:00
cat $TESTDIR /fanboy-esp-track.txt $TESTDIR /fanboy-cz-track.txt $TESTDIR /fanboy-rus-track.txt $TESTDIR /fanboy-vtn-track.txt $TESTDIR /fanboy-tky-track.txt $TESTDIR /fanboy-jpn-track.txt $TESTDIR /fanboy-krn-track.txt $TESTDIR /fanboy-ita-track.txt $TESTDIR /fanboy-pol-track.txt $TESTDIR /fanboy-chn-track.txt $TESTDIR /fanboy-swe-track.txt $TESTDIR /fanboy-ind-track.txt > $TESTDIR /fanboy-track-test-ie.txt
2012-02-12 17:17:23 +13:00
# Merge enhanced for Firefox
2012-08-23 19:01:41 +12:00
cat $HGSERV /enhancedstats-addon.txt $TESTDIR /fanboy-track-test-ie.txt > $TESTDIR /fanboy-track-test.txt
2012-03-18 15:07:43 +13:00
# Create a backup incase addchecksum "zeros" the file
#
cp -f $TESTDIR /fanboy-track-test.txt $TESTDIR /fanboy-track-bak.txt
2012-08-23 00:07:17 +12:00
$ADDCHECKSUM $TESTDIR /fanboy-track-test.txt
2011-06-20 21:11:00 +12:00
2012-03-18 15:07:43 +13:00
# Now lets check if fanboy-track-test.txt isnt zero
2011-06-20 21:11:00 +12:00
#
2012-03-18 15:07:43 +13:00
if [ -s $TESTDIR /fanboy-track-test.txt ] ;
then
cp -f $TESTDIR /fanboy-track-test.txt $MAINDIR /enhancedstats.txt
# mv -f $TESTDIR/fanboy-track-test.txt $MAINDIR/fanboy-tracking-complete.txt
### echo "Updated enhancedstats.txt"
rm -f $MAINDIR /enhancedstats.txt.gz
# Compress file
#
2012-08-23 00:07:17 +12:00
$ZIP $MAINDIR /enhancedstats.txt.gz $TESTDIR /fanboy-track-test.txt > /dev/null
2012-03-18 15:07:43 +13:00
# Log
echo "Updated enhancedstats.txt (script: firefox-adblock-intl-tracking.sh) on `date +'%Y-%m-%d %H:%M:%S'`" >> /var/log/adblock-log.txt
else
# Use the backup file (fanboy-track-test.txt was zero'd by addchecksum)
#
sleep 2
2012-08-15 19:58:35 +12:00
perl $TESTDIR /addChecksum.pl $TESTDIR /fanboy-track-bak.txt
2012-03-18 15:07:43 +13:00
cp -f $TESTDIR /fanboy-track-bak.txt $MAINDIR /enhancedstats.txt
# mv -f $TESTDIR/fanboy-track-test.txt $MAINDIR/fanboy-tracking-complete.txt
### echo "Updated enhancedstats.txt (file was zero)"
rm -f $MAINDIR /enhancedstats.txt.gz
# Compress file
#
2012-08-23 00:07:17 +12:00
$ZIP $MAINDIR /enhancedstats.txt.gz $TESTDIR /fanboy-track-test.txt > /dev/null
2012-03-18 15:07:43 +13:00
# Log
echo "*** ERROR ***: Addchecksum Zero'd the file: enhancedstats.txt (script: firefox-adblock-intl-tracking.sh) on `date +'%Y-%m-%d %H:%M:%S'`" >> /var/log/adblock-log.txt
fi