Allow installer to specify own DNS servers

Offers "other" option.
Gives Installer chance to review settings before continuing.
This commit is contained in:
Daniel Fayette 2016-02-13 22:36:24 -06:00
parent dee8ce587d
commit ecd46f8560

View file

@ -286,9 +286,10 @@ setStaticIPv4() {
} }
setDNS(){ 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 DNSChooseOptions=(Google "" on
OpenDNS "" off) OpenDNS "" off
Other "" off)
DNSchoices=$("${DNSChoseCmd[@]}" "${DNSChooseOptions[@]}" 2>&1 >/dev/tty) DNSchoices=$("${DNSChoseCmd[@]}" "${DNSChooseOptions[@]}" 2>&1 >/dev/tty)
if [[ $? = 0 ]];then if [[ $? = 0 ]];then
case $DNSchoices in case $DNSchoices in
@ -302,6 +303,23 @@ setDNS(){
piholeDNS1="208.67.222.222" piholeDNS1="208.67.222.222"
piholeDNS2="208.67.220.220" 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 esac
else else
echo "::: Cancel selected. Exiting..." echo "::: Cancel selected. Exiting..."
@ -342,8 +360,16 @@ versionCheckDNSmasq(){
$SUDO cp $newFileToInstall $newFileFinalLocation $SUDO cp $newFileToInstall $newFileFinalLocation
echo " done." echo " done."
$SUDO sed -i "s/@INT@/$piholeInterface/" $newFileFinalLocation $SUDO sed -i "s/@INT@/$piholeInterface/" $newFileFinalLocation
$SUDO sed -i "s/@DNS1@/$piholeDNS1/" $newFileFinalLocation if [[ "$piholDNS1" != "" ]]; then
$SUDO sed -i "s/@DNS2@/$piholeDNS2/" $newFileFinalLocation $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() { installScripts() {