Skip to content

Instantly share code, notes, and snippets.

@aido
Created June 12, 2013 18:01
Show Gist options
  • Save aido/5767626 to your computer and use it in GitHub Desktop.
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
#!/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
@war59312
Copy link

@aido Sadly no longer works.

Couldn't compile regex: 11.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment