From ac373545d02771504f7542430956f2de10a85212 Mon Sep 17 00:00:00 2001 From: Chad Howell Date: Mon, 25 Jan 2016 01:27:10 -0500 Subject: [PATCH] versionCheckDNSmasq() fixups versionCheckDNSmasq() fixups per dschaper's suggestions. --- automated install/basic-install.sh | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 4a479749..c05fba94 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -282,12 +282,22 @@ setDNS(){ versionCheckDNSmasq(){ # Check if /etc/dnsmasq.conf is from pihole. If so replace with an original and install new in .d directory - dnsFile="/etc/dnsmasq.conf" + dnsFile1="/etc/dnsmasq.conf" + dnsFile2="/etc/dnsmasq.conf" dnsSearch="addn-hosts=/etc/pihole/gravity.list" - if grep -q $dnsSearch $dnsFile; then - $SUDO mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig - $SUDO cp /etc/.pihole/advanced/dnsmasq.conf.original /etc/dnsmasq.conf + # Check dnsmasq.conf for pihole magic + if grep -q $dnsSearch $dnsFile1; then + # If true, Check dnsmasq.conf.orig for pihole magic + if grep -q $dnsSearch $dnsFile1; then + # If true, use advanced/dnsmasq.conf.original + $SUDO mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig + $SUDO cp /etc/.pihole/advanced/dnsmasq.conf.original /etc/dnsmasq.conf + else + # If false, mv original file back + $SUDO mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig + fi + # If false, This is a fresh install fi $SUDO cp /etc/.pihole/advanced/01-pihole.conf /etc/dnsmasq.d/01-pihole.conf $SUDO sed -i "s/@INT@/$piholeInterface/" /etc/dnsmasq.d/01-pihole.conf