From 5060ed8970821348e9ef09f1b293a1727470f9f1 Mon Sep 17 00:00:00 2001 From: Chad Howell Date: Sat, 30 Jan 2016 20:51:28 -0500 Subject: [PATCH] Add error checking for grep and correct typos --- automated install/basic-install.sh | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index cbf36900..22ab4eee 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -293,19 +293,26 @@ versionCheckDNSmasq(){ dnsFile2="/etc/dnsmasq.conf.orig" dnsSearch="addn-hosts=/etc/pihole/gravity.list" - # Check dnsmasq.conf for pihole magic - if grep -q $dnsSearch $dnsFile1; then - # If true, Check dnsmasq.conf.orig for pihole magic + # Check if /etc/dnsmasq.conf exists + if [ -d "/etc/dnsmasq.conf" ]; then + # If true, Check dnsmasq.conf 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 + # If true, Check dnsmasq.conf.orig for pihole magic + if grep -q $dnsSearch $dnsFile2; then + # If true, use advanced/dnsmasq.conf.original + $SUDO mv -f /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 -f /etc/dnsmasq.conf.orig /etc/dnsmasq.conf + fi + # If false, This is a fresh install fi - # If false, This is a fresh install + else + # If false, use advanced/dnsmasq.conf.original + $SUDO cp /etc/.pihole/advanced/dnsmasq.conf.original /etc/dnsmasq.conf 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 $SUDO sed -i "s/@DNS1@/$piholeDNS1/" /etc/dnsmasq.d/01-pihole.conf