From ecd46f85601b849734d5bcc512cc2f312d69470f Mon Sep 17 00:00:00 2001 From: Daniel Fayette Date: Sat, 13 Feb 2016 22:36:24 -0600 Subject: [PATCH] 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() {