From ecd46f85601b849734d5bcc512cc2f312d69470f Mon Sep 17 00:00:00 2001 From: Daniel Fayette Date: Sat, 13 Feb 2016 22:36:24 -0600 Subject: [PATCH 01/14] Allow installer to specify own DNS servers Offers "other" option. Gives Installer chance to review settings before continuing. --- automated install/basic-install.sh | 34 ++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 00431c69..226f6e41 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -286,9 +286,10 @@ setStaticIPv4() { } setDNS(){ - DNSChoseCmd=(whiptail --separate-output --radiolist "Select Upstream DNS Provider" $r $c 2) + DNSChoseCmd=(whiptail --separate-output --radiolist "Select Upstream DNS Provider" $r $c 3) DNSChooseOptions=(Google "" on - OpenDNS "" off) + OpenDNS "" off + Other "" off) DNSchoices=$("${DNSChoseCmd[@]}" "${DNSChooseOptions[@]}" 2>&1 >/dev/tty) if [[ $? = 0 ]];then case $DNSchoices in @@ -302,6 +303,23 @@ setDNS(){ piholeDNS1="208.67.222.222" piholeDNS2="208.67.220.220" ;; + Other) + until [[ $DNSSettingsCorrect = True ]] + do + piholeDNS=$(whiptail --backtitle "Specify Upstream DNS Provider(s)" --inputbox "Enter your desired upstream DNS provider(s)" $r $c "8.8.8.8, 8.8.4.4" 3>&1 1>&2 2>&3) + piholeDNS1=$(echo $piholeDNS | sed 's/[, \t]\+/,/g' | awk -F, '{print$1}') + piholeDNS2=$(echo $piholeDNS | sed 's/[, \t]\+/,/g' | awk -F, '{print$2}') + + if (whiptail --backtitle "Specify Upstream DNS Provider(s)" --title "Upstream DNS Provider(s)" --yesno "Are these settings correct? + DNS Server 1: $piholeDNS1 + DNS Server 2: $piholeDNS2" $r $c) then + DNSSettingsCorrect=True + else + # If the settings are wrong, the loop continues + DNSSettingsCorrect=False + fi + done + ;; esac else echo "::: Cancel selected. Exiting..." @@ -342,8 +360,16 @@ versionCheckDNSmasq(){ $SUDO cp $newFileToInstall $newFileFinalLocation echo " done." $SUDO sed -i "s/@INT@/$piholeInterface/" $newFileFinalLocation - $SUDO sed -i "s/@DNS1@/$piholeDNS1/" $newFileFinalLocation - $SUDO sed -i "s/@DNS2@/$piholeDNS2/" $newFileFinalLocation + if [[ "$piholDNS1" != "" ]]; then + $SUDO sed -i "s/@DNS1@/$piholeDNS1/" $newFileFinalLocation + else + $SUDO sed -i '/^server=@DNS1@/d' $newFileFinalLocation + fi + if [[ "$piholDNS2" != "" ]]; then + $SUDO sed -i "s/@DNS2@/$piholeDNS2/" $newFileFinalLocation + else + $SUDO sed -i '/^server=@DNS2@/d' $newFileFinalLocation + fi } installScripts() { From 06444c1c27b37f6347b3504559c86139a5faa2bf Mon Sep 17 00:00:00 2001 From: slamanna212 Date: Mon, 15 Feb 2016 17:31:31 -0500 Subject: [PATCH 02/14] Add 3 More DNS Server Choices Durring Install Added Level 3 , Norton, and Comodo DNS Choices --- automated install/basic-install.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 514ac8e6..35bcec41 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -316,6 +316,21 @@ setDNS(){ piholeDNS1="208.67.222.222" piholeDNS2="208.67.220.220" ;; + Level3) + echo "::: Using Level3 servers." + piholeDNS1="4.2.2.1" + piholeDNS2="4.2.2.2" + ;; + Norton) + echo "::: Using Norton ConnectSafe servers." + piholeDNS1="199.85.126.10" + piholeDNS2="199.85.127.10" + ;; + Comodo) + echo "::: Using Comodo Secure servers." + piholeDNS1="8.26.56.26" + piholeDNS2="8.20.247.20" + ;; esac else echo "::: Cancel selected. Exiting..." From 94600c54cbaac14e6e7c0e32b06fce9cddc7b624 Mon Sep 17 00:00:00 2001 From: slamanna212 Date: Mon, 15 Feb 2016 17:54:17 -0500 Subject: [PATCH 03/14] Added Default State for New DNS Options Added default state of off for 3 new DNS options to better match existing code --- automated install/basic-install.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 35bcec41..84ba3921 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -302,7 +302,10 @@ setStaticIPv4() { setDNS(){ DNSChoseCmd=(whiptail --separate-output --radiolist "Select Upstream DNS Provider" $r $c 2) DNSChooseOptions=(Google "" on - OpenDNS "" off) + OpenDNS "" off + Level3 "" off + Norton "" off + Comodo "" off) DNSchoices=$("${DNSChoseCmd[@]}" "${DNSChooseOptions[@]}" 2>&1 >/dev/tty) if [[ $? = 0 ]];then case $DNSchoices in From da959e1296761c3e70d5ab3b812c649fd4424d2b Mon Sep 17 00:00:00 2001 From: slamanna212 Date: Mon, 15 Feb 2016 17:55:14 -0500 Subject: [PATCH 04/14] Increased Size Of Whiptail Dialog Increased Size of Whiptail Dialog to 5 to show all 5 DNS choices --- automated install/basic-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 84ba3921..23aa827f 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -300,7 +300,7 @@ setStaticIPv4() { } setDNS(){ - DNSChoseCmd=(whiptail --separate-output --radiolist "Select Upstream DNS Provider" $r $c 2) + DNSChoseCmd=(whiptail --separate-output --radiolist "Select Upstream DNS Provider" $r $c 5) DNSChooseOptions=(Google "" on OpenDNS "" off Level3 "" off From 432e6d539502795117840b36dd5df35bf433c64e Mon Sep 17 00:00:00 2001 From: Daniel Fayette Date: Tue, 16 Feb 2016 16:47:36 -0600 Subject: [PATCH 05/14] Cleaned up output, Fixed Cancel button --- automated install/basic-install.sh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 600b8fd8..e85593dd 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -305,7 +305,7 @@ setDNS(){ OpenDNS "" off Level3 "" off Norton "" off - Comodo "" off) + Comodo "" off Other "" off) DNSchoices=$("${DNSChoseCmd[@]}" "${DNSChooseOptions[@]}" 2>&1 >/dev/tty) if [[ $? = 0 ]];then @@ -339,12 +339,15 @@ setDNS(){ until [[ $DNSSettingsCorrect = True ]] do piholeDNS=$(whiptail --backtitle "Specify Upstream DNS Provider(s)" --inputbox "Enter your desired upstream DNS provider(s)" $r $c "8.8.8.8, 8.8.4.4" 3>&1 1>&2 2>&3) - piholeDNS1=$(echo $piholeDNS | sed 's/[, \t]\+/,/g' | awk -F, '{print$1}') - piholeDNS2=$(echo $piholeDNS | sed 's/[, \t]\+/,/g' | awk -F, '{print$2}') + if [[ $? = 0 ]];then + piholeDNS1=$(echo $piholeDNS | sed 's/[, \t]\+/,/g' | awk -F, '{print$1}') + piholeDNS2=$(echo $piholeDNS | sed 's/[, \t]\+/,/g' | awk -F, '{print$2}') + else + echo "::: Cancel selected, exiting...." + exit 1 + fi - if (whiptail --backtitle "Specify Upstream DNS Provider(s)" --title "Upstream DNS Provider(s)" --yesno "Are these settings correct? - DNS Server 1: $piholeDNS1 - DNS Server 2: $piholeDNS2" $r $c) then + if (whiptail --backtitle "Specify Upstream DNS Provider(s)" --title "Upstream DNS Provider(s)" --yesno "Are these settings correct?\n DNS Server 1: $piholeDNS1\n DNS Server 2: $piholeDNS2" $r $c) then DNSSettingsCorrect=True else # If the settings are wrong, the loop continues From c396aeed52b844b28e9cbef5ee9a33f932144dae Mon Sep 17 00:00:00 2001 From: Promofaux Date: Wed, 17 Feb 2016 00:07:14 +0000 Subject: [PATCH 06/14] Correct miss-spelled variables on lines 398 and 403 --- automated install/basic-install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index e85593dd..a2bf8f7c 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -395,12 +395,12 @@ versionCheckDNSmasq(){ $SUDO cp $newFileToInstall $newFileFinalLocation echo " done." $SUDO sed -i "s/@INT@/$piholeInterface/" $newFileFinalLocation - if [[ "$piholDNS1" != "" ]]; then + if [[ "$piholeDNS1" != "" ]]; then $SUDO sed -i "s/@DNS1@/$piholeDNS1/" $newFileFinalLocation else $SUDO sed -i '/^server=@DNS1@/d' $newFileFinalLocation fi - if [[ "$piholDNS2" != "" ]]; then + if [[ "$piholeDNS2" != "" ]]; then $SUDO sed -i "s/@DNS2@/$piholeDNS2/" $newFileFinalLocation else $SUDO sed -i '/^server=@DNS2@/d' $newFileFinalLocation From b41608d40b9fb5a7330cd42fba947c4337d412c1 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sat, 20 Feb 2016 14:44:56 +0000 Subject: [PATCH 07/14] Include fix for regex in verifyFreeDiskSpace() --- automated install/basic-install.sh | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index a2bf8f7c..505c843d 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -117,15 +117,19 @@ welcomeDialogs() { verifyFreeDiskSpace() { - # 25MB is the minimum space needed (20MB install + 5MB one day of logs.) - requiredFreeBytes=25600 - - existingFreeBytes=`df -lkP / | awk '{print $4}' | tail -1` - - if [[ $existingFreeBytes -lt $requiredFreeBytes ]]; then - whiptail --msgbox --backtitle "Insufficient Disk Space" --title "Insufficient Disk Space" "\nYour system appears to be low on disk space. pi-hole recomends a minimum of $requiredFreeBytes Bytes.\nYou only have $existingFreeBytes Free.\n\nIf this is a new install you may need to expand your disk.\n\nTry running:\n 'sudo raspi-config'\nChoose the 'expand file system option'\n\nAfter rebooting, run this installation again.\n\ncurl -L install.pi-hole.net | bash\n" $r $c - exit 1 - fi + # 25MB is the minimum space needed (20MB install + 5MB one day of logs.) + requiredFreeBytes=25600 + + existingFreeBytes=`df -lk / 2>&1 | awk '{print $4}' | head -2 | tail -1` + if ! [[ "$existingFreeBytes" =~ ^([0-9])*$ ]]; then + existingFreeBytes=`df -lk /dev 2>&1 | awk '{print $4}' | head -2 | tail -1` + fi + + if [[ $existingFreeBytes -lt $requiredFreeBytes ]]; then + echo "$existingFreeBytes is less than $requiredFreeBytes" + echo "Insufficient free space, exiting..." + exit 1 + fi } From 7001edcd1df8390315ae6295abfaf6ae0d57dac4 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sat, 20 Feb 2016 15:00:03 +0000 Subject: [PATCH 08/14] Change 'Other' to 'Custom', add explanation to whiptail. Convert spaces to tabs. --- automated install/basic-install.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 505c843d..43cd6c78 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -304,13 +304,13 @@ setStaticIPv4() { } setDNS(){ - DNSChoseCmd=(whiptail --separate-output --radiolist "Select Upstream DNS Provider" $r $c 6) + DNSChoseCmd=(whiptail --separate-output --radiolist "Select Upstream DNS Provider. To use your own, select Custom" $r $c 6) DNSChooseOptions=(Google "" on OpenDNS "" off Level3 "" off Norton "" off Comodo "" off - Other "" off) + Custom "" off) DNSchoices=$("${DNSChoseCmd[@]}" "${DNSChooseOptions[@]}" 2>&1 >/dev/tty) if [[ $? = 0 ]];then case $DNSchoices in @@ -339,10 +339,10 @@ setDNS(){ piholeDNS1="8.26.56.26" piholeDNS2="8.20.247.20" ;; - Other) - until [[ $DNSSettingsCorrect = True ]] - do - piholeDNS=$(whiptail --backtitle "Specify Upstream DNS Provider(s)" --inputbox "Enter your desired upstream DNS provider(s)" $r $c "8.8.8.8, 8.8.4.4" 3>&1 1>&2 2>&3) + Custom) + until [[ $DNSSettingsCorrect = True ]] + do + piholeDNS=$(whiptail --backtitle "Specify Upstream DNS Provider(s)" --inputbox "Enter your desired upstream DNS provider(s)" $r $c "8.8.8.8, 8.8.4.4" 3>&1 1>&2 2>&3) if [[ $? = 0 ]];then piholeDNS1=$(echo $piholeDNS | sed 's/[, \t]\+/,/g' | awk -F, '{print$1}') piholeDNS2=$(echo $piholeDNS | sed 's/[, \t]\+/,/g' | awk -F, '{print$2}') @@ -351,14 +351,14 @@ setDNS(){ exit 1 fi - if (whiptail --backtitle "Specify Upstream DNS Provider(s)" --title "Upstream DNS Provider(s)" --yesno "Are these settings correct?\n DNS Server 1: $piholeDNS1\n DNS Server 2: $piholeDNS2" $r $c) then + if (whiptail --backtitle "Specify Upstream DNS Provider(s)" --title "Upstream DNS Provider(s)" --yesno "Are these settings correct?\n DNS Server 1: $piholeDNS1\n DNS Server 2: $piholeDNS2" $r $c) then DNSSettingsCorrect=True else # If the settings are wrong, the loop continues DNSSettingsCorrect=False fi - done - ;; + done + ;; esac else echo "::: Cancel selected. Exiting..." From 8687d25d88cd9772ab7b13b54ad7f89e67e8e88b Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sat, 20 Feb 2016 15:12:13 +0000 Subject: [PATCH 09/14] make prepopulation of freetext on custom DNS provider a bit more intelligent --- automated install/basic-install.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 43cd6c78..18531f27 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -304,7 +304,7 @@ setStaticIPv4() { } setDNS(){ - DNSChoseCmd=(whiptail --separate-output --radiolist "Select Upstream DNS Provider. To use your own, select Custom" $r $c 6) + DNSChoseCmd=(whiptail --separate-output --radiolist "Select Upstream DNS Provider. To use your own, select Custom." $r $c 6) DNSChooseOptions=(Google "" on OpenDNS "" off Level3 "" off @@ -342,7 +342,15 @@ setDNS(){ Custom) until [[ $DNSSettingsCorrect = True ]] do - piholeDNS=$(whiptail --backtitle "Specify Upstream DNS Provider(s)" --inputbox "Enter your desired upstream DNS provider(s)" $r $c "8.8.8.8, 8.8.4.4" 3>&1 1>&2 2>&3) + if [ ! $piholeDNS1 ]; then + prePopulate="" + elif [ $piholeDNS1 ] && [ ! $piholeDNS2 ]; then + prePopulate="$piholeDNS1" + elif [ $piholeDNS1 ] && [ $piholeDNS2 ]; then + prePopulate="$piholeDNS1, $piholeDNS2" + fi + + piholeDNS=$(whiptail --backtitle "Specify Upstream DNS Provider(s)" --inputbox "Enter your desired upstream DNS provider(s), seperated by a comma.\n\nFor example '8.8.8.8, 8.8.4.4'" $r $c "$prePopulate" 3>&1 1>&2 2>&3) if [[ $? = 0 ]];then piholeDNS1=$(echo $piholeDNS | sed 's/[, \t]\+/,/g' | awk -F, '{print$1}') piholeDNS2=$(echo $piholeDNS | sed 's/[, \t]\+/,/g' | awk -F, '{print$2}') From b14b182084e571fa72e44f9b687bf4da0040ccff Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sat, 20 Feb 2016 15:17:57 +0000 Subject: [PATCH 10/14] change regex to test for one or more numbers, not 0 or more numbers. --- automated install/basic-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 18531f27..b8834951 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -121,7 +121,7 @@ verifyFreeDiskSpace() { requiredFreeBytes=25600 existingFreeBytes=`df -lk / 2>&1 | awk '{print $4}' | head -2 | tail -1` - if ! [[ "$existingFreeBytes" =~ ^([0-9])*$ ]]; then + if ! [[ "$existingFreeBytes" =~ ^([0-9])+$ ]]; then existingFreeBytes=`df -lk /dev 2>&1 | awk '{print $4}' | head -2 | tail -1` fi From f3978446039ccd8ceaaf042aec33c84aa023239d Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sat, 20 Feb 2016 16:08:02 +0000 Subject: [PATCH 11/14] Remove conflicted merge markup. Not sure how that got through. --- automated install/basic-install.sh | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 1a021089..75f32116 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -117,7 +117,6 @@ welcomeDialogs() { verifyFreeDiskSpace() { -<<<<<<< HEAD # 25MB is the minimum space needed (20MB install + 5MB one day of logs.) requiredFreeBytes=25600 @@ -131,20 +130,6 @@ verifyFreeDiskSpace() { echo "Insufficient free space, exiting..." exit 1 fi -======= - # 25MB is the minimum space needed (20MB install + 5MB one day of logs.) - requiredFreeBytes=25600 - - existingFreeBytes=`df -lk / 2>&1 | awk '{print $4}' | head -2 | tail -1` - if ! [[ "$existingFreeBytes" =~ ^[0-9]\+$ ]]; then - existingFreeBytes=`df -lk /dev 2>&1 | awk '{print $4}' | head -2 | tail -1` - fi - - if [[ $existingFreeBytes -lt $requiredFreeBytes ]]; then - whiptail --msgbox --backtitle "Insufficient Disk Space" --title "Insufficient Disk Space" "\nYour system appears to be low on disk space. pi-hole recomends a minimum of $requiredFreeBytes Bytes.\nYou only have $existingFreeBytes Free.\n\nIf this is a new install you may need to expand your disk.\n\nTry running:\n 'sudo raspi-config'\nChoose the 'expand file system option'\n\nAfter rebooting, run this installation again.\n\ncurl -L install.pi-hole.net | bash\n" $r $c - exit 1 - fi ->>>>>>> development } From 800d2f0859eaa70d8a72607392c3d8c13706472c Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sat, 20 Feb 2016 16:17:29 +0000 Subject: [PATCH 12/14] Add back in whiptail dialog to verifyFreeDiskSpace() --- automated install/basic-install.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 75f32116..c20447c2 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -125,7 +125,8 @@ verifyFreeDiskSpace() { existingFreeBytes=`df -lk /dev 2>&1 | awk '{print $4}' | head -2 | tail -1` fi - if [[ $existingFreeBytes -lt $requiredFreeBytes ]]; then + if [[ $existingFreeBytes -lt $requiredFreeBytes ]]; then + whiptail --msgbox --backtitle "Insufficient Disk Space" --title "Insufficient Disk Space" "\nYour system appears to be low on disk space. pi-hole recomends a minimum of $requiredFreeBytes Bytes.\nYou only have $existingFreeBytes Free.\n\nIf this is a new install you may need to expand your disk.\n\nTry running:\n 'sudo raspi-config'\nChoose the 'expand file system option'\n\nAfter rebooting, run this installation again.\n\ncurl -L install.pi-hole.net | bash\n" $r $c echo "$existingFreeBytes is less than $requiredFreeBytes" echo "Insufficient free space, exiting..." exit 1 From 0ebb7eecdb87f7a74304ac31a489e13cfda74e4c Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sat, 20 Feb 2016 17:33:20 +0000 Subject: [PATCH 13/14] Verify Custom DNS IP is a valid IP address --- automated install/basic-install.sh | 61 ++++++++++++++++++++++++++---- 1 file changed, 54 insertions(+), 7 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index c20447c2..e6deca29 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -304,6 +304,23 @@ setStaticIPv4() { fi } +function valid_ip() +{ + local ip=$1 + local stat=1 + + if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then + OIFS=$IFS + IFS='.' + ip=($ip) + IFS=$OIFS + [[ ${ip[0]} -le 255 && ${ip[1]} -le 255 \ + && ${ip[2]} -le 255 && ${ip[3]} -le 255 ]] + stat=$? + fi + return $stat +} + setDNS(){ DNSChoseCmd=(whiptail --separate-output --radiolist "Select Upstream DNS Provider. To use your own, select Custom." $r $c 6) DNSChooseOptions=(Google "" on @@ -343,9 +360,16 @@ setDNS(){ Custom) until [[ $DNSSettingsCorrect = True ]] do + + strInvalid="Invalid" + if [ ! $piholeDNS1 ]; then - prePopulate="" - elif [ $piholeDNS1 ] && [ ! $piholeDNS2 ]; then + if [ ! $piholeDNS2 ]; then + prePopulate="" + else + prePopulate=", $piholeDNS2" + fi + elif [ $piholeDNS1 ] && [ ! $piholeDNS2 ]; then prePopulate="$piholeDNS1" elif [ $piholeDNS1 ] && [ $piholeDNS2 ]; then prePopulate="$piholeDNS1, $piholeDNS2" @@ -355,16 +379,39 @@ setDNS(){ if [[ $? = 0 ]];then piholeDNS1=$(echo $piholeDNS | sed 's/[, \t]\+/,/g' | awk -F, '{print$1}') piholeDNS2=$(echo $piholeDNS | sed 's/[, \t]\+/,/g' | awk -F, '{print$2}') + + if ! valid_ip $piholeDNS1 || [ ! $piholeDNS1 ]; then + piholeDNS1=$strInvalid + fi + + if ! valid_ip $piholeDNS2 && [ $piholeDNS2 ]; then + piholeDNS2=$strInvalid + fi + else echo "::: Cancel selected, exiting...." exit 1 fi - - if (whiptail --backtitle "Specify Upstream DNS Provider(s)" --title "Upstream DNS Provider(s)" --yesno "Are these settings correct?\n DNS Server 1: $piholeDNS1\n DNS Server 2: $piholeDNS2" $r $c) then - DNSSettingsCorrect=True - else - # If the settings are wrong, the loop continues + + if [ $piholeDNS1 == $strInvalid ] || [ $piholeDNS2 == $strInvalid ]; then + whiptail --msgbox --backtitle "Invalid IP" --title "Invalid IP" "One or both entered IP addresses were invalid. Please try again.\n\n DNS Server 1: $piholeDNS1\n DNS Server 2: $piholeDNS2" $r $c + + if [ $piholeDNS1 == $strInvalid ]; then + piholeDNS1="" + fi + + if [ $piholeDNS2 == $strInvalid ]; then + piholeDNS2="" + fi + DNSSettingsCorrect=False + else + if (whiptail --backtitle "Specify Upstream DNS Provider(s)" --title "Upstream DNS Provider(s)" --yesno "Are these settings correct?\n DNS Server 1: $piholeDNS1\n DNS Server 2: $piholeDNS2" $r $c) then + DNSSettingsCorrect=True + else + # If the settings are wrong, the loop continues + DNSSettingsCorrect=False + fi fi done ;; From ca2d3a192cbefda4b5d50ab38f06cf64d63e25b4 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sun, 21 Feb 2016 18:38:34 +0000 Subject: [PATCH 14/14] add double bracket notation to lines 396, 399, 403 . Fixes error raised by @jacobsalmela --- automated install/basic-install.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index e6deca29..c20308ab 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -393,14 +393,14 @@ setDNS(){ exit 1 fi - if [ $piholeDNS1 == $strInvalid ] || [ $piholeDNS2 == $strInvalid ]; then + if [[ $piholeDNS1 == $strInvalid ]] || [[ $piholeDNS2 == $strInvalid ]]; then whiptail --msgbox --backtitle "Invalid IP" --title "Invalid IP" "One or both entered IP addresses were invalid. Please try again.\n\n DNS Server 1: $piholeDNS1\n DNS Server 2: $piholeDNS2" $r $c - if [ $piholeDNS1 == $strInvalid ]; then + if [[ $piholeDNS1 == $strInvalid ]]; then piholeDNS1="" fi - if [ $piholeDNS2 == $strInvalid ]; then + if [[ $piholeDNS2 == $strInvalid ]]; then piholeDNS2="" fi