ports/84915: new port: www/bannerfilter - A squid redirect script for filtering web banners

Emanuel Haupt ehaupt at critical.ch
Sun Aug 14 16:30:26 UTC 2005


>Number:         84915
>Category:       ports
>Synopsis:       new port: www/bannerfilter - A squid redirect script for filtering web banners
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sun Aug 14 16:30:15 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator:     Emanuel Haupt
>Release:        FreeBSD 5.4-RELEASE-p6 i386
>Organization:
>Environment:
System: FreeBSD beaver.critical.ch 5.4-RELEASE-p6 FreeBSD 5.4-RELEASE-p6 #0: Wed Jul 27 20:19:15 CEST 2005 root at beaver.critical.ch:/usr/obj/usr/src/RELENG_5_4/src/sys/BEAVER i386


	
>Description:
new port: www/bannerfilter - A squid redirect script for filtering web banners

BannerFilter is a redirect script for the Squid proxy server, designed to block
advertising banners on the Web. Unlike most other solutions, it also
automatically closes popup windows.

>How-To-Repeat:
	
>Fix:

	



--- bannerfilter.shar begins here ---
# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	bannerfilter
#	bannerfilter/files
#	bannerfilter/files/patch-update.sh
#	bannerfilter/Makefile
#	bannerfilter/pkg-descr
#	bannerfilter/distinfo
#	bannerfilter/pkg-plist
#
echo c - bannerfilter
mkdir -p bannerfilter > /dev/null 2>&1
echo c - bannerfilter/files
mkdir -p bannerfilter/files > /dev/null 2>&1
echo x - bannerfilter/files/patch-update.sh
sed 's/^X//' >bannerfilter/files/patch-update.sh << 'END-of-bannerfilter/files/patch-update.sh'
X--- update.sh.orig	Mon May 31 23:52:25 2004
X+++ update.sh	Sun Aug 14 17:51:57 2005
X@@ -21,14 +21,21 @@
X # running as, or if you don't have killall, change RELOAD to 0.
X 
X # Choose your HTTP downloader:
X-CMD="lynx -source"
X+# CMD="lynx -source"
X # CMD="wget -q -O -"
X # CMD="curl -s"
X+CMD="fetch -q -o -"
X 
X # Reload with "killall -HUP redirector.pl" if the files have changed?
X RELOAD=1
X # RELOAD=0
X 
X+# Directory with the data files
X+CONFIGDIR="/usr/local/etc/bannerfilter"
X+
X+# temp dir
X+TEMPDIR="/tmp"
X+
X ##########################################################################
X 
X # Earliest version of BannerFilter compatible with your data files:
X@@ -37,18 +44,18 @@
X # Read the data files from the current directory, and get the modification
X # date from each.  Redirect errors to /dev/null.  If the files don't exist,
X # we get blank values.
X-OLDBANNERS=`grep "^# last modified " banners.data 2>/dev/null|cut -d " " -f4`
X-OLDPOPUPS=`grep "^# last modified " popups.data 2>/dev/null|cut -d " " -f4`
X-OLDFRAMES=`grep "^# last modified " frames.data 2>/dev/null|cut -d " " -f4`
X-OLDEXCEPTIONS=`grep "^# last modified " exceptions.data 2>/dev/null|cut -d " " -f4`
X+OLDBANNERS=`grep "^# last modified " $CONFIGDIR/banners.data 2>/dev/null|cut -d " " -f4`
X+OLDPOPUPS=`grep "^# last modified " $CONFIGDIR/popups.data 2>/dev/null|cut -d " " -f4`
X+OLDFRAMES=`grep "^# last modified " $CONFIGDIR/frames.data 2>/dev/null|cut -d " " -f4`
X+OLDEXCEPTIONS=`grep "^# last modified " $CONFIGDIR/exceptions.data 2>/dev/null|cut -d " " -f4`
X 
X # Get the earliest version of BannerFilter compatible with the
X # new data files, and see whether we need to upgrade
X-$CMD http://phroggy.com/bannerfilter/version.txt>version.tmp \
X+$CMD http://phroggy.com/bannerfilter/version.txt> $TEMPDIR/version.tmp \
X || { echo "Error retrieving version.txt"; exit; }
X-if ( grep "^version " version.tmp>/dev/null ); then
X-  NEW=`grep "^version " version.tmp|cut -d " " -f2`
X-  rm version.tmp
X+if ( grep "^version " $TEMPDIR/version.tmp>/dev/null ); then
X+  NEW=`grep "^version " $TEMPDIR/version.tmp|cut -d " " -f2`
X+  rm $TEMPDIR/version.tmp
X else
X   echo "Error: something unexpected in version.txt"
X   exit
X@@ -64,55 +71,63 @@
X 
X # Download all four data files
X 
X-$CMD http://phroggy.com/bannerfilter/banners.data>banners.data.tmp \
X-&& grep "^# banners.data$" banners.data.tmp>/dev/null \
X+$CMD http://phroggy.com/bannerfilter/banners.data>$CONFIGDIR/banners.data.tmp \
X+&& grep "^# banners.data$" $CONFIGDIR/banners.data.tmp>/dev/null \
X || { echo "Error retrieving banners.data"; exit; }
X 
X-$CMD http://phroggy.com/bannerfilter/popups.data>popups.data.tmp \
X-&& grep "^# popups.data$" popups.data.tmp>/dev/null \
X+$CMD http://phroggy.com/bannerfilter/popups.data>$CONFIGDIR/popups.data.tmp \
X+&& grep "^# popups.data$" $CONFIGDIR/popups.data.tmp>/dev/null \
X || { echo "Error retrieving popups.data"; exit; }
X 
X-$CMD http://phroggy.com/bannerfilter/frames.data>frames.data.tmp \
X-&& grep "^# frames.data$" frames.data.tmp>/dev/null \
X+$CMD http://phroggy.com/bannerfilter/frames.data>$CONFIGDIR/frames.data.tmp \
X+&& grep "^# frames.data$" $CONFIGDIR/frames.data.tmp>/dev/null \
X || { echo "Error retrieving frames.data"; exit; }
X 
X-$CMD http://phroggy.com/bannerfilter/exceptions.data>exceptions.data.tmp \
X-&& grep "^# exceptions.data$" exceptions.data.tmp>/dev/null \
X+$CMD http://phroggy.com/bannerfilter/exceptions.data>$CONFIGDIR/exceptions.data.tmp \
X+&& grep "^# exceptions.data$" $CONFIGDIR/exceptions.data.tmp>/dev/null \
X || { echo "Error retrieving exceptions.data"; exit; }
X 
X # Get the modification dates of the files we just downloaded, compare
X # them to what we already have, and only overwrite if necessary.
X # By using cat to overwrite, we preserve ownership and permissions.
X 
X-NEWBANNERS=`grep "^# last modified " banners.data.tmp|cut -d " " -f4`
X-NEWPOPUPS=`grep "^# last modified " popups.data.tmp|cut -d " " -f4`
X-NEWFRAMES=`grep "^# last modified " frames.data.tmp|cut -d " " -f4`
X-NEWEXCEPTIONS=`grep "^# last modified " exceptions.data.tmp|cut -d " " -f4`
X+NEWBANNERS=`grep "^# last modified " $CONFIGDIR/banners.data.tmp|cut -d " " -f4`
X+NEWPOPUPS=`grep "^# last modified " $CONFIGDIR/popups.data.tmp|cut -d " " -f4`
X+NEWFRAMES=`grep "^# last modified " $CONFIGDIR/frames.data.tmp|cut -d " " -f4`
X+NEWEXCEPTIONS=`grep "^# last modified " $CONFIGDIR/exceptions.data.tmp|cut -d " " -f4`
X CHANGED=0
X if [ "$OLDBANNERS" != "$NEWBANNERS" ]; then
X-  cat banners.data.tmp > banners.data
X+  cat $CONFIGDIR/banners.data.tmp > $CONFIGDIR/banners.data
X   CHANGED=1
X fi
X if [ "$OLDPOPUPS" != "$NEWPOPUPS" ]; then
X-  cat popups.data.tmp > popups.data
X+  cat $CONFIGDIR/popups.data.tmp > $CONFIGDIR/popups.data
X   CHANGED=1
X fi
X if [ "$OLDFRAMES" != "$NEWFRAMES" ]; then
X-  cat frames.data.tmp > frames.data
X+  cat $CONFIGDIR/frames.data.tmp > $CONFIGDIR/frames.data
X   CHANGED=1
X fi
X if [ "$OLDEXCEPTIONS" != "$NEWEXCEPTIONS" ]; then
X-  cat exceptions.data.tmp > exceptions.data
X+  cat $CONFIGDIR/exceptions.data.tmp > $CONFIGDIR/exceptions.data
X   CHANGED=1
X fi
X 
X # Clean up our temp files
X-rm banners.data.tmp
X-rm popups.data.tmp
X-rm frames.data.tmp
X-rm exceptions.data.tmp
X+rm $CONFIGDIR/banners.data.tmp
X+rm $CONFIGDIR/popups.data.tmp
X+rm $CONFIGDIR/frames.data.tmp
X+rm $CONFIGDIR/exceptions.data.tmp
X 
X # Send all instances of redirector.pl a signal to reload the data files
X-if [ $RELOAD == 1 ] && [ $CHANGED == 1 ]; then
X-  killall -HUP redirector.pl
X+if [ "$RELOAD" = "1" ] && [ "$CHANGED" = "1" ]; then
X+  echo -n "Sending signal HUP to all redirector.pl instances... "
X+  for pid in $(ps wwwax | grep -i redirector.pl | grep -v grep | awk '{print $1}')
X+  do
X+    echo -n "$pid "
X+    kill -HUP $pid
X+  done
X+  echo
X+else
X+  echo "No changes."
X fi
END-of-bannerfilter/files/patch-update.sh
echo x - bannerfilter/Makefile
sed 's/^X//' >bannerfilter/Makefile << 'END-of-bannerfilter/Makefile'
X# New ports collection makefile for:	bannerfilter
X# Date created:				14 Aug 2005
X# Whom:					Emanuel Haupt <ehaupt at critical.ch>
X#
X# $FreeBSD$
X#
X
XPORTNAME=	bannerfilter
XPORTVERSION=	1.31
XCATEGORIES=	www
XMASTER_SITES=	http://phroggy.com/files/unix/
X
XMAINTAINER=	ehaupt at critical.ch
XCOMMENT=	A squid redirect script for filtering web banners
X
XRUN_DEPENDS=	squid:${PORTSDIR}/www/squid
X
XUSE_PERL5=	yes
XUSE_REINPLACE=	yes
XNO_BUILD=	yes
X
XWWW_ROOT?=	www
XPLIST_SUB+=	WWW_ROOT="${WWW_ROOT}"
XCONFIG_FILES=	bannerfilter.conf banners.data banners.local.data \
X		exceptions.data exceptions.local.data frames.data \
X		frames.local.data popups.data popups.local.data
X
X.include <bsd.port.pre.mk>
X
X.if ${PERL_LEVEL} < 500806
XIGNORE=		needs Perl 5.8.6 or above (lang/perl5.8)
X.endif
X
Xpost-patch:
X	@${REINPLACE_CMD} -e \
X		's|/usr/local/etc|${PREFIX}/etc|; s|/usr/bin/perl|${PERL}|' \
X		${WRKSRC}/redirector.pl
X	@${REINPLACE_CMD} -e \
X		's|^;\ \(DATA\ =\ \).*|\1${PREFIX}/etc/${PORTNAME}/|' \
X		${WRKSRC}/${PORTNAME}.conf
X	@${REINPLACE_CMD} -e \
X		's|^\(CONFIGDIR=\).*|\1"${PREFIX}/etc/${PORTNAME}"|' \
X		${WRKSRC}/update.sh
X
Xdo-install:
X	${MKDIR} ${PREFIX}/libexec/${PORTNAME}
X	${INSTALL_SCRIPT} ${WRKSRC}/redirector.pl ${PREFIX}/libexec/${PORTNAME}
X	${INSTALL_SCRIPT} ${WRKSRC}/update.sh \
X		${PREFIX}/bin/update-bannerfilter-rules
X	${MKDIR} ${PREFIX}/etc/${PORTNAME}
X.for f in ${CONFIG_FILES}
X	${INSTALL_DATA} ${WRKSRC}/${f} ${PREFIX}/etc/${PORTNAME}/${f}.default
X.if !exists(${PREFIX}/etc/${PORTNAME}/${f})
X	${INSTALL_DATA} ${WRKSRC}/${f} ${PREFIX}/etc/${PORTNAME}
X.endif
X.endfor
X	${CP} -R ${WRKSRC}/www ${PREFIX}/${WWW_ROOT}/${PORTNAME}
X
Xpost-install:
X	@${ECHO_MSG} ""
X	@${ECHO_MSG} "==========================================================================="
X	@${ECHO_MSG} ""
X	@${ECHO_MSG} "Please add the following redirector config directive to your squid.conf:"
X	@${ECHO_MSG} "   redirect_program ${PREFIX}/libexec/bannerfilter/redirector.pl"
X	@${ECHO_MSG} ""
X	@${ECHO_MSG} "Make sure ${PREFIX}/${WWW_ROOT}/${PORTNAME} is available under"
X	@${ECHO_MSG} "   http://localhost/${PORTNAME}"
X	@${ECHO_MSG} ""
X	@${ECHO_MSG} "==========================================================================="
X	@${ECHO_MSG} ""
X
X.include <bsd.port.post.mk>
END-of-bannerfilter/Makefile
echo x - bannerfilter/pkg-descr
sed 's/^X//' >bannerfilter/pkg-descr << 'END-of-bannerfilter/pkg-descr'
XBannerFilter is a redirect script for the Squid proxy server, designed to block
Xadvertising banners on the Web. Unlike most other solutions, it also
Xautomatically closes popup windows.
X
XWWW: http://phroggy.com/bannerfilter/
X
X- ehaupt
Xehaupt at critical.ch
END-of-bannerfilter/pkg-descr
echo x - bannerfilter/distinfo
sed 's/^X//' >bannerfilter/distinfo << 'END-of-bannerfilter/distinfo'
XMD5 (bannerfilter-1.31.tar.gz) = 329a8a6e2b04b21a6f77a365e62e0881
XSIZE (bannerfilter-1.31.tar.gz) = 36294
END-of-bannerfilter/distinfo
echo x - bannerfilter/pkg-plist
sed 's/^X//' >bannerfilter/pkg-plist << 'END-of-bannerfilter/pkg-plist'
Xbin/update-bannerfilter-rules
X at unexec if cmp -s %D/etc/bannerfilter/bannerfilter.conf %D/etc/bannerfilter/bannerfilter.conf.default; then rm -f %D/etc/bannerfilter/bannerfilter.conf; fi
Xetc/bannerfilter/bannerfilter.conf.default
X at exec [ -f %B/etc/bannerfilter/bannerfilter.conf ] || cp %B/%f %B/etc/bannerfilter/bannerfilter.conf
X at unexec if cmp -s %D/etc/bannerfilter/banners.data %D/etc/bannerfilter/banners.data.default; then rm -f %D/etc/bannerfilter/banners.data; fi
Xetc/bannerfilter/banners.data.default
X at exec [ -f %B/etc/bannerfilter/banners.data ] || cp %B/%f %B/etc/bannerfilter/banners.data
X at unexec if cmp -s %D/etc/bannerfilter/banners.local.data %D/etc/bannerfilter/banners.local.data.default; then rm -f %D/etc/bannerfilter/banners.local.data; fi
Xetc/bannerfilter/banners.local.data.default
X at exec [ -f %B/etc/bannerfilter/banners.local.data ] || cp %B/%f %B/etc/bannerfilter/banners.local.data
X at unexec if cmp -s %D/etc/bannerfilter/exceptions.data %D/etc/bannerfilter/exceptions.data.default; then rm -f %D/etc/bannerfilter/exceptions.data; fi
Xetc/bannerfilter/exceptions.data.default
X at exec [ -f %B/etc/bannerfilter/exceptions.data ] || cp %B/%f %B/etc/bannerfilter/exceptions.data
X at unexec if cmp -s %D/etc/bannerfilter/exceptions.local.data %D/etc/bannerfilter/exceptions.local.data.default; then rm -f %D/etc/bannerfilter/exceptions.local.data; fi
Xetc/bannerfilter/exceptions.local.data.default
X at exec [ -f %B/etc/bannerfilter/exceptions.local.data ] || cp %B/%f %B/etc/bannerfilter/exceptions.local.data
X at unexec if cmp -s %D/etc/bannerfilter/frames.data %D/etc/bannerfilter/frames.data.default; then rm -f %D/etc/bannerfilter/frames.data; fi
Xetc/bannerfilter/frames.data.default
X at exec [ -f %B/etc/bannerfilter/frames.data ] || cp %B/%f %B/etc/bannerfilter/frames.data
X at unexec if cmp -s %D/etc/bannerfilter/frames.local.data %D/etc/bannerfilter/frames.local.data.default; then rm -f %D/etc/bannerfilter/frames.local.data; fi
Xetc/bannerfilter/frames.local.data.default
X at exec [ -f %B/etc/bannerfilter/frames.local.data ] || cp %B/%f %B/etc/bannerfilter/frames.local.data
X at unexec if cmp -s %D/etc/bannerfilter/popups.data %D/etc/bannerfilter/popups.data.default; then rm -f %D/etc/bannerfilter/popups.data; fi
Xetc/bannerfilter/popups.data.default
X at exec [ -f %B/etc/bannerfilter/popups.data ] || cp %B/%f %B/etc/bannerfilter/popups.data
X at unexec if cmp -s %D/etc/bannerfilter/popups.local.data %D/etc/bannerfilter/popups.local.data.default; then rm -f %D/etc/bannerfilter/popups.local.data; fi
Xetc/bannerfilter/popups.local.data.default
X at exec [ -f %B/etc/bannerfilter/popups.local.data ] || cp %B/%f %B/etc/bannerfilter/popups.local.data
Xlibexec/bannerfilter/redirector.pl
X%%WWW_ROOT%%/bannerfilter/banner.gif
X%%WWW_ROOT%%/bannerfilter/blocked.html
X%%WWW_ROOT%%/bannerfilter/empty.js
X%%WWW_ROOT%%/bannerfilter/flash.swf
X%%WWW_ROOT%%/bannerfilter/goatsecx.gif
X%%WWW_ROOT%%/bannerfilter/header_tile.gif
X%%WWW_ROOT%%/bannerfilter/hometown.html
X%%WWW_ROOT%%/bannerfilter/namezero.html
X%%WWW_ROOT%%/bannerfilter/nbci.html
X%%WWW_ROOT%%/bannerfilter/null.gif
X%%WWW_ROOT%%/bannerfilter/popup.html
X%%WWW_ROOT%%/bannerfilter/test.html
X%%WWW_ROOT%%/bannerfilter/xbbackground.gif
X%%WWW_ROOT%%/bannerfilter/xoom.html
X%%WWW_ROOT%%/bannerfilter/yahoo.html
X at unexec rmdir %D/etc/bannerfilter 2> /dev/null || true
X at dirrm libexec/bannerfilter
X at dirrm %%WWW_ROOT%%/bannerfilter
END-of-bannerfilter/pkg-plist
exit
--- bannerfilter.shar ends here ---

>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-ports-bugs mailing list