From 9a2862de62578b22e9c7292b995ba798b5cb27aa Mon Sep 17 00:00:00 2001 From: jacobsalmela Date: Sat, 18 Jul 2015 09:39:18 -0500 Subject: [PATCH] closes #24 whitelist without running gravity.sh It's pretty slow because /etc/hosts is so large, but it works. You can add any number of domains as arguments and it will search for and remove each one. Maybe someone smarter knows how to make it faster... --- advanced/Scripts/whitelist.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100755 advanced/Scripts/whitelist.sh diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh new file mode 100755 index 00000000..947e798c --- /dev/null +++ b/advanced/Scripts/whitelist.sh @@ -0,0 +1,13 @@ +#!/bin/bash +# For each argument passed to this script +for var in "$@" +do + echo "Whitelisting $var..." + # Use sed to search for the domain in /etc/hosts and remove it using an in-place edit + sed -i "/$var/d" /etc/hosts + # Also add the domain to the whitelist.txt in /etc/pihole + echo "$var" >> /etc/pihole/whitelist.txt +done +echo "** $# domain(s) whitelisted." +# Force dnsmasq to reload /etc/hosts +kill -HUP $(pidof dnsmasq) \ No newline at end of file