Created
June 12, 2013 18:01
-
-
Save aido/5767626 to your computer and use it in GitHub Desktop.
Use wget and sed to update Polipo forbidden file from http://easylist-downloads.adblockplus.org/easylist.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash +xv | |
declare WGET=/usr/bin/wget | |
declare SED=/bin/sed | |
declare INVOKE=/usr/sbin/invoke-rc.d | |
#declare TORIFY=/usr/bin/torify | |
#declare TORRESOLVE=/usr/bin/tor-resolve | |
declare -i EXIT_VALUE=0 | |
declare ADBLOCKER=easylist-downloads.adblockplus.org | |
declare EASYLIST=easylist.txt | |
declare EASYPRIVACY=easyprivacy.txt | |
declare FORBIDDEN=/etc/polipo/forbidden | |
if [[ $EUID -ne 0 ]]; then | |
echo -e "\n\E[31m\E[1mERROR:\E[22m This script must be run as root\E[00m\n" 1>&2 | |
EXIT_VALUE=1 | |
else | |
$WGET --quiet http://$ADBLOCKER/$EASYLIST --no-check-certificate --spider && $WGET --quiet http://$ADBLOCKER/$EASYLIST --no-check-certificate -O- | $SED -e '/^\[/d' -e '/^!/d' -e '/^#/d' -e '/^~/d' -e '/^@/d' -e '/^\/adverti/d' -e 's/^+/\\+/g' -e '/##/d' -e 's/|*//g' -e 's/\./\\\./g' -e 's/\*/\.\*/g' -e 's/\?/\\\?/g' -e 's/\$.*//g' -e 's/\^/[\\\/:\\\.=\&\\\?\\\+\\\-\\\ \]+/g' > $FORBIDDEN | |
# $WGET --quiet http://$ADBLOCKER/$EASYPRIVACY --no-check-certificate --spider && $WGET --quiet http://$ADBLOCKER/$EASYPRIVACY --no-check-certificate -O- | $SED -e '/^\[/d' -e '/^!/d' -e '/^#/d' -e '/^~/d' -e '/^@/d' -e '/^\/adverti/d' -e 's/^+/\\+/g' -e '/##/d' -e 's/|*//g' -e 's/\./\\\./g' -e 's/\*/\.\*/g' -e 's/\?/\\\?/g' -e 's/\$.*//g' -e 's/\^/[\\\/:\\\.=\&\\\?\\\+\\\-\\\ \]+/g' >> $FORBIDDEN | |
# $TORIFY $WGET --quiet http://$($TORRESOLVE $ADBLOCKER)/$EASYLIST --no-check-certificate -O- | $SED -e '/^\[/d' -e '/^!/d' -e '/^#/d' -e '/^~/d' -e '/^@/d' -e '/^\/adverti/d' -e 's/^+/\\+/g' -e '/##/d' -e 's/|*//g' -e 's/\./\\\./g' -e 's/\*/\.\*/g' -e 's/\?/\\\?/g' -e 's/\$.*//g' -e 's/\^/[\\\/:\\\.=\&\\\?\\\+\\\-\\\ \]+/g' > $FORBIDDEN | |
# $TORIFY $WGET --quiet http://$($TORRESOLVE $ADBLOCKER)/$EASYPRIVACY --no-check-certificate -O- | $SED -e '/^\[/d' -e '/^!/d' -e '/^#/d' -e '/^~/d' -e '/^@/d' -e '/^\/adverti/d' -e 's/^+/\\+/g' -e '/##/d' -e 's/|*//g' -e 's/\./\\\./g' -e 's/\*/\.\*/g' -e 's/\?/\\\?/g' -e 's/\$.*//g' -e 's/\^/[\\\/:\\\.=\&\\\?\\\+\\\-\\\ \]+/g' >> $FORBIDDEN | |
$INVOKE polipo-chroot restart | |
fi | |
exit $EXIT_VALUE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@aido Sadly no longer works.