#!/bin/sh
#-------------------------------------------------------------------------
# A simple shell script to allow the starting/stopping/restarting of the
# black_hole_http_server.pl script that was written by Sean Burke. This
# Black-hole server can then be used by John LoVerso's ad-blocking file,
# called 'no-ads.pac', for browsers that need some sort of response.
# Note: no-ads.pac can be found here:
# ;
#
#
# Instructions:
# -------------
# 1) First download the perl script from here:
#
#
# 2) Then rename it to 'blackhole' and save it in /usr/local/bin. Make sure
# the x bit is set to allow execution of the perl script. To make sure,
# run this command as root: chmod a+x /usr/local/bin/blackhole
#
# 3) Save this shell script as 'bhpd' and place it anywhere in your path,
# such as'/usr/local/bin/bhpd'. Now you can start the server by running
# this command, 'bhpd start'. To stop the server, run this command,
# 'bhpd stop'. To restart it, run 'bhpd restart'. You will need to make
# sure it is executable, also (chmod a+x /usr/local/bin/bhpd).
#
# NOTE: For users of Slackware or a BSD, you can name this shell script
# 'rc.bhpd' and drop it in the /etc/rc.d/ directory. Then add these
# lines in /etc/rc.d/rc.local:
#
# # Start the Black-hole proxy server
# if [ -x /usr/rc.d/rc.bhpd ] ; then
# /etc/rc.d/rc.bhpd start
# fi
#
# Now you can activate or deactivate the starting of the server by
# simply changing the executable bit. To allow the server to start
# during boot, use the command 'chmod a+x /usr/rc.d/rc.bhpd'. To
# prevent the server from starting during boot, run this command,
# 'chmod a-x /usr/rc.d/rc.bhpd'.
#
# The above lines will also work in a user's ~/.bashrc script or
# equivalent if they can't use it as a system wide startup script. Then
# whenever the user log ons, the black-hole server will start up
# automatically. It will still require root priveleges to stop the
# server, though.
#
#-------------------------------------------------------------------------
# Start bhpd:
bhpd_start() {
if [ -x /usr/local/bin/blackhole ]; then
echo "Starting Black-hole proxy server..."
( /usr/local/bin/blackhole ) &
fi
}
# Stop bhpd:
bhpd_stop() {
echo "Stopping Black-hole proxy server..."
killall blackhole
}
# Restart bhpd:
bhpd_restart() {
bhpd_stop
sleep 1
bhpd_start
}
case "$1" in
'start')
bhpd_start
;;
'stop')
bhpd_stop
;;
'restart')
bhpd_restart
;;
*)
echo "usage $0 start|stop|restart"
esac