fanboy-adblock/scripts/firefox2opera.sh

112 lines
4.0 KiB
Bash
Raw Normal View History

2012-05-20 22:34:49 +12:00
#!/bin/bash
#
2012-10-11 23:58:09 +13:00
# Fanboy Adblock list Firefox-Opera bash script v2.0 (11/10/2012)
2012-05-20 22:34:49 +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-19 03:27:12 +12:00
# Version history
#
2012-10-11 23:58:09 +13:00
# 3.0 Re-write script, cleaner and better, removed lots of cruft.
2012-08-19 03:27:12 +12:00
2012-05-20 22:34:49 +12:00
# Variables for directorys
#
2012-10-11 23:58:09 +13: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"
export MAINDIR="/tmp/Ramdisk/www/adblock"
export SPLITDIR="/tmp/Ramdisk/www/adblock/split/test"
export HGSERV="/tmp/hgstuff/fanboy-adblock-list"
export TESTDIR="/tmp/work"
export DATE="`date`"
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"
export TWIDGE="/usr/bin/twidge update"
export IEDIR="/tmp/work/ie"
export IESUBS="/tmp/work/ie/subscriptions"
export IRONDIR="/tmp/Ramdisk/www/adblock/iron"
export PERL="/usr/bin/perl"
# Check mirror dir exists and its not a symlink
2012-07-15 00:27:44 +12:00
#
2012-10-11 23:58:09 +13:00
if [ -d "/var/hgstuff/fanboy-adblock-list" ] && [ -h "/tmp/hgstuff" ]; then
export HGSERV="/var/hgstuff/fanboy-adblock-list"
echo "HGSERV=/var/hgstuff/fanboy-adblock-list"
cd /tmp/hgstuff/fanboy-adblock-list
$NICE $HG pull
$NICE $HG update
else
# If not, its stored here
export HGSERV="/tmp/hgstuff/fanboy-adblock-list"
echo "HGSERV=/tmp/hgstuff/fanboy-adblock-list"
cd /tmp/hgstuff/fanboy-adblock-list
$NICE $HG pull
$NICE $HG update
2012-08-19 03:27:12 +12:00
fi
# Check that the www server is up before proceding
2012-05-20 22:34:49 +12:00
#
2012-10-12 00:10:00 +13:00
if [ -d "/tmp/Ramdisk/www/adblock" ]; then
2012-05-20 22:34:49 +12:00
2012-08-19 03:27:12 +12:00
# Fanboy-Adblock
#
2012-10-14 12:38:40 +13:00
$NICE $PERL $HGSERV/scripts/createOperaFilters_new.pl $MAINDIR/fanboy-adblock.txt --urlfilter $MAINDIR/opera/urlfilter-adblock.bak --nocomments --everythingisfirstparty --nocss --ignorewhitelist
2012-10-11 23:58:09 +13:00
# Fanboy-Tracking
#
2012-10-14 12:38:40 +13:00
$NICE $PERL $HGSERV/scripts/createOperaFilters_new.pl $MAINDIR/fanboy-tracking.txt --urlfilter $MAINDIR/opera/urlfilter-tracking.bak --nocomments --everythingisfirstparty --nocss --ignorewhitelist
# Because Tracking list is merged with Adblock, remove the top 5 lines
#
sed -i -e '1,5d' $MAINDIR/opera/urlfilter-tracking.bak
2012-05-20 22:34:49 +12:00
2012-10-22 23:25:37 +13:00
# Remove Bad opera filters
#
sed -i -e '/\/adsWrapper\./d' $MAINDIR/opera/urlfilter-adblock.bak
2012-10-23 23:33:46 +13:00
# http://forums.fanboy.co.nz/forums/viewtopic.php?f=5&t=15558
sed -i -e '/eloqua.com/d' $MAINDIR/opera/urlfilter-tracking.bak
2012-10-25 23:57:40 +13:00
# http://forums.fanboy.co.nz/forums/viewtopic.php?f=8&p=40974
sed -i -e '/analytics_prod./d' $MAINDIR/opera/urlfilter-tracking.bak
sed -i -e '/wikia-beacon.com/d' $MAINDIR/opera/urlfilter-tracking.bak
2012-10-26 11:36:24 +13:00
# http://forums.fanboy.co.nz/forums/viewtopic.php?f=6&t=7043
sed -i -e '/webtrends.com/d' $MAINDIR/opera/urlfilter-tracking.bak
2012-10-22 23:25:37 +13:00
2012-10-11 23:58:09 +13:00
# Include Opera urlfilter header file
2012-08-19 03:27:12 +12:00
#
2012-10-11 23:58:09 +13:00
$CAT $HGSERV/opera/urlfilter-header.txt $MAINDIR/opera/urlfilter-adblock.bak > $MAINDIR/opera/urlfilter-adblock.bak2
# Adblock+Tracking
$CAT $HGSERV/opera/urlfilter-header.txt $MAINDIR/opera/urlfilter-adblock.bak $MAINDIR/opera/urlfilter-tracking.bak > $MAINDIR/opera/urlfilter-tracking.bak2
2012-05-20 22:34:49 +12:00
2012-10-11 23:58:09 +13:00
# Remove empty lines
2012-08-19 03:27:12 +12:00
#
2012-10-11 23:58:09 +13:00
sed -i -e '/^$/d' $MAINDIR/opera/urlfilter-adblock.bak2
sed -i -e '/^$/d' $MAINDIR/opera/urlfilter-tracking.bak2
2012-05-20 22:34:49 +12:00
2012-10-11 23:58:09 +13:00
# Checksums
2012-08-19 03:27:12 +12:00
#
2012-10-11 23:58:09 +13:00
$PERL $HGSERV/scripts/addChecksum-opera.pl $MAINDIR/opera/urlfilter-adblock.bak2
2012-10-12 00:10:00 +13:00
$PERL $HGSERV/scripts/addChecksum-opera.pl $MAINDIR/opera/urlfilter-tracking.bak2
2012-05-20 22:34:49 +12:00
2012-10-11 23:58:09 +13:00
# GZIP
2012-08-19 03:27:12 +12:00
#
2012-10-11 23:58:09 +13:00
cp -f $MAINDIR/opera/urlfilter-adblock.bak2 $MAINDIR/opera/urlfilter.ini
cp -f $MAINDIR/opera/urlfilter-tracking.bak2 $MAINDIR/opera/complete/urlfilter.ini
# Clear old files first
#
rm -rf $MAINDIR/opera/urlfilter.ini.gz $MAINDIR/opera/complete/urlfilter.ini.gz
2012-10-11 23:58:09 +13:00
$ZIP $MAINDIR/opera/urlfilter.ini.gz $MAINDIR/opera/urlfilter-adblock.bak2 > /dev/null
$ZIP $MAINDIR/opera/complete/urlfilter.ini.gz $MAINDIR/opera/urlfilter-tracking.bak2 > /dev/null
2012-08-19 03:27:12 +12:00
2012-10-11 23:58:09 +13:00
# Remove Backup files
2012-08-19 03:27:12 +12:00
#
2012-10-11 23:58:09 +13:00
rm -rf $MAINDIR/opera/urlfilter-tracking.bak* $MAINDIR/opera/urlfilter-adblock.bak*
2012-08-19 03:27:12 +12:00
fi
2012-05-20 22:34:49 +12:00