mirror of
https://github.com/pi-hole/pi-hole
synced 2024-11-18 06:08:21 +00:00
Merge pull request #327 from pi-hole/slamanna212-development
Additional upstream DNS choices, plus ability to add custom upstream DNS
This commit is contained in:
commit
3ec9b3b021
@ -117,18 +117,20 @@ welcomeDialogs() {
|
||||
|
||||
|
||||
verifyFreeDiskSpace() {
|
||||
# 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
|
||||
# 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
|
||||
echo "$existingFreeBytes is less than $requiredFreeBytes"
|
||||
echo "Insufficient free space, exiting..."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
@ -302,10 +304,31 @@ 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" $r $c 2)
|
||||
DNSChoseCmd=(whiptail --separate-output --radiolist "Select Upstream DNS Provider. To use your own, select Custom." $r $c 6)
|
||||
DNSChooseOptions=(Google "" on
|
||||
OpenDNS "" off)
|
||||
OpenDNS "" off
|
||||
Level3 "" off
|
||||
Norton "" off
|
||||
Comodo "" off
|
||||
Custom "" off)
|
||||
DNSchoices=$("${DNSChoseCmd[@]}" "${DNSChooseOptions[@]}" 2>&1 >/dev/tty)
|
||||
if [[ $? = 0 ]];then
|
||||
case $DNSchoices in
|
||||
@ -319,6 +342,79 @@ 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"
|
||||
;;
|
||||
Custom)
|
||||
until [[ $DNSSettingsCorrect = True ]]
|
||||
do
|
||||
|
||||
strInvalid="Invalid"
|
||||
|
||||
if [ ! $piholeDNS1 ]; then
|
||||
if [ ! $piholeDNS2 ]; then
|
||||
prePopulate=""
|
||||
else
|
||||
prePopulate=", $piholeDNS2"
|
||||
fi
|
||||
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}')
|
||||
|
||||
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 [[ $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
|
||||
;;
|
||||
esac
|
||||
else
|
||||
echo "::: Cancel selected. Exiting..."
|
||||
@ -359,8 +455,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 [[ "$piholeDNS1" != "" ]]; then
|
||||
$SUDO sed -i "s/@DNS1@/$piholeDNS1/" $newFileFinalLocation
|
||||
else
|
||||
$SUDO sed -i '/^server=@DNS1@/d' $newFileFinalLocation
|
||||
fi
|
||||
if [[ "$piholeDNS2" != "" ]]; then
|
||||
$SUDO sed -i "s/@DNS2@/$piholeDNS2/" $newFileFinalLocation
|
||||
else
|
||||
$SUDO sed -i '/^server=@DNS2@/d' $newFileFinalLocation
|
||||
fi
|
||||
}
|
||||
|
||||
installScripts() {
|
||||
|
Loading…
Reference in New Issue
Block a user