fanboy-adblock/scripts/list-grabber-opera.sh

109 lines
4.2 KiB
Bash
Raw Normal View History

2012-03-09 11:59:47 +13:00
#!/bin/bash
#
2012-09-06 00:56:45 +12:00
# Fanboy Adblock list grabber Opera script v2.2 (06/09/2012)
2012-03-09 11:59:47 +13:00
# Dual License CCby3.0/GPLv2
# http://creativecommons.org/licenses/by/3.0/
# http://www.gnu.org/licenses/gpl-2.0.html
#
2012-08-15 18:42:25 +12:00
# Version history
#
2012-09-06 00:40:58 +12:00
# 2.2 Fix bug where Opera uncompressed wasnt being copied over.
2012-08-30 15:13:14 +12:00
# 2.1 Re-implement the iron list generator
2012-08-26 18:03:56 +12:00
# 2.0 Re-write Opera code, and split off regional list
2012-08-15 18:42:25 +12:00
# 1.8 Allow list to be stored in ramdisk
2012-03-09 11:59:47 +13:00
# Variables for directorys
#
2012-08-26 18:03:56 +12:00
export ZIP="nice -n 19 /usr/local/bin/7za a -mx=9 -y -tgzip"
2012-08-15 18:42:25 +12:00
export NICE="nice -n 19"
2012-08-26 18:03:56 +12:00
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"
2012-08-15 18:42:25 +12:00
export DATE="`date`"
2012-08-26 18:03:56 +12:00
export ADDCHECKSUM="nice -n 19 perl $HGSERV/scripts/addChecksum-opera.pl"
export LOGFILE="/etc/crons/log.txt"
2012-08-15 18:42:25 +12:00
export HG="/usr/local/bin/hg"
2012-08-26 18:03:56 +12:00
export SHA256SUM="/usr/bin/sha256sum"
2012-08-15 18:42:25 +12:00
export IEDIR="/tmp/ieramdisk"
2012-08-26 18:03:56 +12:00
export TWIDGE="/usr/bin/twidge update"
2012-08-15 18:42:25 +12:00
export SUBS="/tmp/ieramdisk/subscriptions"
2012-08-26 18:03:56 +12:00
export IRONDIR="/tmp/Ramdisk/www/adblock/iron"
# Check mirror dir exists and its not a symlink
2012-09-06 12:20:12 +12:00
#
if [ -d "/var/hgstuff/fanboy-adblock-list" ] && [ -h "/tmp/hgstuff" ]; then
export HGSERV="/var/hgstuff/fanboy-adblock-list"
else
# If not, its stored here
export HGSERV="/tmp/hgstuff/fanboy-adblock-list"
2012-09-06 12:20:12 +12:00
fi
2012-08-26 18:03:56 +12:00
# Opera Standard Filter
if [ -n $HGSERV/opera/urlfilter.ini ]
2012-03-09 11:59:47 +13:00
then
2012-08-26 18:03:56 +12:00
if diff $HGSERV/opera/urlfilter.ini $MAINDIR/opera/urlfilter.ini > /dev/null ; then
2012-07-01 12:09:48 +12:00
# echo "No Changes detected: urlfilter.ini" > /dev/null
2012-08-26 18:03:56 +12:00
echo "No Changes detected: urlfilter.ini (script: list-grabber-opera.sh) on `date +'%Y-%m-%d %H:%M:%S'`" >> $LOGFILE
2012-03-09 11:59:47 +13:00
else
2012-07-01 12:09:48 +12:00
# echo "Updated: urlfilter.ini"
2012-08-26 18:03:56 +12:00
cp -f $HGSERV/opera/urlfilter.ini $TESTDIR/opera/urlfilter.ini
$ADDCHECKSUM $TESTDIR/opera/urlfilter.ini
2012-09-06 00:40:58 +12:00
cp -f $TESTDIR/opera/urlfilter.ini $MAINDIR/opera/urlfilter.ini
2012-03-09 11:59:47 +13:00
# Properly wipe old file.
2012-08-15 19:33:22 +12:00
rm -rf $MAINDIR/opera/urlfilter.ini.gz
2012-08-26 18:03:56 +12:00
$ZIP $MAINDIR/opera/urlfilter.ini.gz $TESTDIR/opera/urlfilter.ini > /dev/null
2012-03-09 11:59:47 +13:00
# Generate Iron script
# Turn off for the time being.
2012-08-26 18:03:56 +12:00
$HGSERV/scripts/iron/adblock-iron-generator.sh
2012-03-09 13:58:00 +13:00
2012-08-26 18:03:56 +12:00
cp -f $TESTDIR/opera/urfilter-stats2.ini $MAINDIR/opera/complete/urlfilter.ini
2012-03-09 11:59:47 +13:00
# Properly wipe old file.
2012-08-26 18:03:56 +12:00
rm -rf $MAINDIR/opera/complete/urlfilter.ini.gz
$ZIP $MAINDIR/opera/complete/urlfilter.ini.gz $TESTDIR/opera/urfilter-stats.ini > /dev/null
2012-03-09 11:59:47 +13:00
# Generate Iron script
2012-08-30 15:13:14 +12:00
$HGSERV/scripts/iron/adblock-iron-generator-tracker.sh
# Regional Opera
2012-08-26 18:03:56 +12:00
$HGSERV/scripts/list-grabber-opera-regional.sh
2012-03-09 11:59:47 +13:00
fi
else
2012-08-26 18:03:56 +12:00
# echo "Something went bad, file size is 0"
2012-08-30 15:13:14 +12:00
echo "urlfilter.ini/urlfilter-stats size is zero, please fix." >> $LOGFILE
2012-03-09 11:59:47 +13:00
fi
2012-03-09 13:58:00 +13:00
2012-08-26 18:03:56 +12:00
# Opera Tracking Filter
if [ -n $HGSERV/opera/urlfilter-stats.ini ]
2012-03-09 11:59:47 +13:00
then
2012-08-26 18:03:56 +12:00
if diff $HGSERV/opera/urlfilter-stats.ini $MAINDIR/opera/urlfilter-stats.ini > /dev/null ; then
# echo "No Changes detected: urlfilter-stats.ini" > /dev/null
echo "No Changes detected: urlfilter-stats.ini (script: list-grabber-opera.sh) on `date +'%Y-%m-%d %H:%M:%S'`" >> $LOGFILE
else
echo "Updated: complete/urlfilter.ini"
# echo "Updated: urlfilter.ini"
cp -f $HGSERV/opera/urlfilter-stats.ini $TESTDIR/opera/urlfilter-stats.ini
# Keep a copy of stats also (used for comparison)
cp -f $HGSERV/opera/urlfilter-stats.ini $MAINDIR/opera/urlfilter-stats.ini
# Combine tracking filter
sed '/^$/d' $HGSERV/opera/urlfilter-stats.ini > $TESTDIR/opera/urlfilter-stats.ini
cat $MAINDIR/opera/urlfilter.ini $TESTDIR/opera/urlfilter-stats.ini > $TESTDIR/opera/urfilter-stats2.ini
$ADDCHECKSUM $TESTDIR/opera/urfilter-stats2.ini
#
cp -f $TESTDIR/opera/urfilter-stats2.ini $MAINDIR/opera/complete/urlfilter.ini
2012-03-09 11:59:47 +13:00
# Properly wipe old file.
2012-08-26 18:03:56 +12:00
rm -rf $MAINDIR/opera/complete/urlfilter.ini.gz
$ZIP $MAINDIR/opera/complete/urlfilter.ini.gz $TESTDIR/opera/urfilter-stats2.ini > /dev/null
2012-03-09 11:59:47 +13:00
# Generate Iron script
2012-08-30 15:13:14 +12:00
$HGSERV/scripts/iron/adblock-iron-generator-tracker.sh
# Regional Opera
2012-08-26 18:03:56 +12:00
$HGSERV/scripts/list-grabber-opera-regional.sh
2012-03-09 11:59:47 +13:00
fi
else
2012-08-26 18:03:56 +12:00
# echo "Something went bad, file size is 0"
2012-08-30 15:13:14 +12:00
echo "urlfilter.ini/urlfilter-stats size is zero, please fix." >> $LOGFILE
2012-03-09 11:59:47 +13:00
fi
2012-03-09 13:58:00 +13:00
2012-03-09 11:59:47 +13:00
2012-07-01 12:09:48 +12:00