Skip to content

Instantly share code, notes, and snippets.

@spacecowboy
Created August 25, 2015 14:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spacecowboy/ae40c0ff45e405b37e2e to your computer and use it in GitHub Desktop.
Save spacecowboy/ae40c0ff45e405b37e2e to your computer and use it in GitHub Desktop.
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