From 2131149fdac4a75b98243a3d4882a7194a5d8f0b Mon Sep 17 00:00:00 2001 From: Jacob Salmela Date: Sun, 8 Jun 2014 10:03:56 -0500 Subject: [PATCH] Create gravity.sh --- gravity.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 gravity.sh diff --git a/gravity.sh b/gravity.sh new file mode 100644 index 00000000..41bfb204 --- /dev/null +++ b/gravity.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# URL to pull list of known ad servers from +adListURL="http://pgl.yoyo.org/adservers/serverlist.php?hostformat=dnsmasq&showintro=0&mimetype=plaintext" + +# Address to send ads to +piholeIP="127.0.0.1" + +# Where the list of ad servers are stored once downloaded +# Any file in /etc/dnsmasq.d is loaded automatically when the service starts +adFile="/etc/dnsmasq.d/adList.conf" + +# The temporary file for holding +eventHorizion="/etc/dnsmasq.d/adList.conf.tmp" + +# Parses out the default 127.0.0.1 address and replaces it with the IP where ads will be sent +curl $adListURL | sed "s/127\.0\.0\.1/$piholeIP/" > $eventHorizion + +# If the temporary list of ad servers already exists (the eventHorizion) +if [ -f "$eventHorizion" ];then + # Then replace it as the new ad file + mv -f $eventHorizion $adFile +else + echo "Error building the ad list, please try again." + exit 1 +fi