mirror of
https://github.com/pi-hole/pi-hole
synced 2025-01-07 06:30:55 +00:00
setDNS
whiptail direct, not in array.
Signed-off-by: Dan Schaper <dan.schaper@pi-hole.net>
This commit is contained in:
parent
80a3bce6d5
commit
c58a95ca2e
@ -429,86 +429,88 @@ valid_ip() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setDNS() {
|
setDNS() {
|
||||||
DNSChooseCmd=(whiptail --separate-output --radiolist "Select Upstream DNS Provider. To use your own, select Custom." ${r} ${c} 6)
|
local DNSSettingsCorrect
|
||||||
|
|
||||||
DNSChooseOptions=(Google "" on
|
DNSChooseOptions=(Google "" on
|
||||||
OpenDNS "" off
|
OpenDNS "" off
|
||||||
Level3 "" off
|
Level3 "" off
|
||||||
Norton "" off
|
Norton "" off
|
||||||
Comodo "" off
|
Comodo "" off
|
||||||
Custom "" off)
|
Custom "" off)
|
||||||
DNSchoices=$("${DNSChooseCmd[@]}" "${DNSChooseOptions[@]}" 2>&1 >/dev/tty) || \
|
DNSchoices=$(whiptail --separate-output --radiolist "Select Upstream DNS Provider. To use your own, select Custom." ${r} ${c} 6 \
|
||||||
{ echo "::: Cancel selected. Exiting"; exit 1; }
|
"${DNSChooseOptions[@]}" 2>&1 >/dev/tty) || \
|
||||||
case ${DNSchoices} in
|
{ echo "::: Cancel selected. Exiting"; exit 1; }
|
||||||
Google)
|
case ${DNSchoices} in
|
||||||
echo "::: Using Google DNS servers."
|
Google)
|
||||||
PIHOLE_DNS_1="8.8.8.8"
|
echo "::: Using Google DNS servers."
|
||||||
PIHOLE_DNS_2="8.8.4.4"
|
PIHOLE_DNS_1="8.8.8.8"
|
||||||
;;
|
PIHOLE_DNS_2="8.8.4.4"
|
||||||
OpenDNS)
|
;;
|
||||||
echo "::: Using OpenDNS servers."
|
OpenDNS)
|
||||||
PIHOLE_DNS_1="208.67.222.222"
|
echo "::: Using OpenDNS servers."
|
||||||
PIHOLE_DNS_2="208.67.220.220"
|
PIHOLE_DNS_1="208.67.222.222"
|
||||||
;;
|
PIHOLE_DNS_2="208.67.220.220"
|
||||||
Level3)
|
;;
|
||||||
echo "::: Using Level3 servers."
|
Level3)
|
||||||
PIHOLE_DNS_1="4.2.2.1"
|
echo "::: Using Level3 servers."
|
||||||
PIHOLE_DNS_2="4.2.2.2"
|
PIHOLE_DNS_1="4.2.2.1"
|
||||||
;;
|
PIHOLE_DNS_2="4.2.2.2"
|
||||||
Norton)
|
;;
|
||||||
echo "::: Using Norton ConnectSafe servers."
|
Norton)
|
||||||
PIHOLE_DNS_1="199.85.126.10"
|
echo "::: Using Norton ConnectSafe servers."
|
||||||
PIHOLE_DNS_2="199.85.127.10"
|
PIHOLE_DNS_1="199.85.126.10"
|
||||||
;;
|
PIHOLE_DNS_2="199.85.127.10"
|
||||||
Comodo)
|
;;
|
||||||
echo "::: Using Comodo Secure servers."
|
Comodo)
|
||||||
PIHOLE_DNS_1="8.26.56.26"
|
echo "::: Using Comodo Secure servers."
|
||||||
PIHOLE_DNS_2="8.20.247.20"
|
PIHOLE_DNS_1="8.26.56.26"
|
||||||
;;
|
PIHOLE_DNS_2="8.20.247.20"
|
||||||
Custom)
|
;;
|
||||||
until [[ ${DNSSettingsCorrect} = True ]]; do
|
Custom)
|
||||||
strInvalid="Invalid"
|
until [[ ${DNSSettingsCorrect} = True ]]; do
|
||||||
if [ ! ${PIHOLE_DNS_1} ]; then
|
strInvalid="Invalid"
|
||||||
if [ ! ${PIHOLE_DNS_2} ]; then
|
if [ ! ${PIHOLE_DNS_1} ]; then
|
||||||
prePopulate=""
|
if [ ! ${PIHOLE_DNS_2} ]; then
|
||||||
else
|
prePopulate=""
|
||||||
prePopulate=", ${PIHOLE_DNS_2}"
|
else
|
||||||
fi
|
prePopulate=", ${PIHOLE_DNS_2}"
|
||||||
elif [ ${PIHOLE_DNS_1} ] && [ ! ${PIHOLE_DNS_2} ]; then
|
|
||||||
prePopulate="${PIHOLE_DNS_1}"
|
|
||||||
elif [ ${PIHOLE_DNS_1} ] && [ ${PIHOLE_DNS_2} ]; then
|
|
||||||
prePopulate="${PIHOLE_DNS_1}, ${PIHOLE_DNS_2}"
|
|
||||||
fi
|
fi
|
||||||
|
elif [ ${PIHOLE_DNS_1} ] && [ ! ${PIHOLE_DNS_2} ]; then
|
||||||
|
prePopulate="${PIHOLE_DNS_1}"
|
||||||
|
elif [ ${PIHOLE_DNS_1} ] && [ ${PIHOLE_DNS_2} ]; then
|
||||||
|
prePopulate="${PIHOLE_DNS_1}, ${PIHOLE_DNS_2}"
|
||||||
|
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) || \
|
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) || \
|
||||||
{ echo "::: Cancel selected. Exiting"; exit 1; }
|
{ echo "::: Cancel selected. Exiting"; exit 1; }
|
||||||
PIHOLE_DNS_1=$(echo "${piholeDNS}" | sed 's/[, \t]\+/,/g' | awk -F, '{print$1}')
|
PIHOLE_DNS_1=$(echo "${piholeDNS}" | sed 's/[, \t]\+/,/g' | awk -F, '{print$1}')
|
||||||
PIHOLE_DNS_2=$(echo "${piholeDNS}" | sed 's/[, \t]\+/,/g' | awk -F, '{print$2}')
|
PIHOLE_DNS_2=$(echo "${piholeDNS}" | sed 's/[, \t]\+/,/g' | awk -F, '{print$2}')
|
||||||
if ! valid_ip "${PIHOLE_DNS_1}" || [ ! "${PIHOLE_DNS_1}" ]; then
|
if ! valid_ip "${PIHOLE_DNS_1}" || [ ! "${PIHOLE_DNS_1}" ]; then
|
||||||
PIHOLE_DNS_1=${strInvalid}
|
PIHOLE_DNS_1=${strInvalid}
|
||||||
|
fi
|
||||||
|
if ! valid_ip "${PIHOLE_DNS_2}" && [ "${PIHOLE_DNS_2}" ]; then
|
||||||
|
PIHOLE_DNS_2=${strInvalid}
|
||||||
|
fi
|
||||||
|
if [[ ${PIHOLE_DNS_1} == "${strInvalid}" ]] || [[ ${PIHOLE_DNS_2} == "${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: $PIHOLE_DNS_1\n DNS Server 2: ${PIHOLE_DNS_2}" ${r} ${c}
|
||||||
|
if [[ ${PIHOLE_DNS_1} == "${strInvalid}" ]]; then
|
||||||
|
PIHOLE_DNS_1=""
|
||||||
fi
|
fi
|
||||||
if ! valid_ip "${PIHOLE_DNS_2}" && [ "${PIHOLE_DNS_2}" ]; then
|
if [[ ${PIHOLE_DNS_2} == "${strInvalid}" ]]; then
|
||||||
PIHOLE_DNS_2=${strInvalid}
|
PIHOLE_DNS_2=""
|
||||||
fi
|
fi
|
||||||
if [[ ${PIHOLE_DNS_1} == "${strInvalid}" ]] || [[ ${PIHOLE_DNS_2} == "${strInvalid}" ]]; then
|
DNSSettingsCorrect=False
|
||||||
whiptail --msgbox --backtitle "Invalid IP" --title "Invalid IP" "One or both entered IP addresses were invalid. Please try again.\n\n DNS Server 1: $PIHOLE_DNS_1\n DNS Server 2: ${PIHOLE_DNS_2}" ${r} ${c}
|
else
|
||||||
if [[ ${PIHOLE_DNS_1} == "${strInvalid}" ]]; then
|
if (whiptail --backtitle "Specify Upstream DNS Provider(s)" --title "Upstream DNS Provider(s)" --yesno "Are these settings correct?\n DNS Server 1: $PIHOLE_DNS_1\n DNS Server 2: ${PIHOLE_DNS_2}" ${r} ${c}); then
|
||||||
PIHOLE_DNS_1=""
|
DNSSettingsCorrect=True
|
||||||
fi
|
else
|
||||||
if [[ ${PIHOLE_DNS_2} == "${strInvalid}" ]]; then
|
# If the settings are wrong, the loop continues
|
||||||
PIHOLE_DNS_2=""
|
DNSSettingsCorrect=False
|
||||||
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: $PIHOLE_DNS_1\n DNS Server 2: ${PIHOLE_DNS_2}" ${r} ${c}); then
|
|
||||||
DNSSettingsCorrect=True
|
|
||||||
else
|
|
||||||
# If the settings are wrong, the loop continues
|
|
||||||
DNSSettingsCorrect=False
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
done
|
fi
|
||||||
;;
|
done
|
||||||
esac
|
;;
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
setLogging() {
|
setLogging() {
|
||||||
|
Loading…
Reference in New Issue
Block a user