Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Download hphosts file and convert it to squidGuard formatting.
#!/bin/bash
TEMPDIR=/tmp/hphostspfsense
# Move to temporary directory
mkdir -p $TEMPDIR
rm -rf $TEMPDIR/*
cd $TEMPDIR
# Download latest hp-hosts file
wget http://hosts-file.net/download/hosts.zip
# Extract
unzip hosts.zip
# Make category folder
mkdir hphosts
# Remove lines which do not matter
# sed '0,/BAD HOSTS BEGIN HERE/d'
cat hosts.txt | sed '/localhost/d' > hphosts/domains
cat hphosts/domains | sed '/^#/d' > hphosts/domains.temp
# Format it for pfsense
cat hphosts/domains.temp | sed -r 's/127.0.0.1\s+//' > hphosts/domains
# Remove temp file
rm hphosts/domains.temp
# Make package
tar -caf pfsensehphosts.tar.gz hphosts
# Copy to destination, change destination to whatever you need
cp pfsensehphosts.tar.gz /var/www/publicwebsite/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.