You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if [[ $existingFreeBytes-lt$requiredFreeBytes ]];then
126
-
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
127
-
exit 1
128
-
fi
120
+
# 25MB is the minimum space needed (20MB install + 5MB one day of logs.)
if [[ $existingFreeBytes-lt$requiredFreeBytes ]];then
129
+
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
130
+
echo"$existingFreeBytes is less than $requiredFreeBytes"
131
+
echo"Insufficient free space, exiting..."
132
+
exit 1
133
+
fi
129
134
}
130
135
131
136
@@ -299,10 +304,31 @@ setStaticIPv4() {
299
304
fi
300
305
}
301
306
307
+
functionvalid_ip()
308
+
{
309
+
local ip=$1
310
+
local stat=1
311
+
312
+
if [[ $ip=~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]];then
313
+
OIFS=$IFS
314
+
IFS='.'
315
+
ip=($ip)
316
+
IFS=$OIFS
317
+
[[ ${ip[0]}-le 255 &&${ip[1]}-le 255 \
318
+
&&${ip[2]}-le 255 &&${ip[3]}-le 255 ]]
319
+
stat=$?
320
+
fi
321
+
return$stat
322
+
}
323
+
302
324
setDNS(){
303
-
DNSChoseCmd=(whiptail --separate-output --radiolist "Select Upstream DNS Provider"$r$c2)
325
+
DNSChoseCmd=(whiptail --separate-output --radiolist "Select Upstream DNS Provider. To use your own, select Custom."$r$c6)
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>&11>&22>&3)
379
+
if [[ $?= 0 ]];then
380
+
piholeDNS1=$(echo $piholeDNS| sed 's/[, \t]\+/,/g'| awk -F, '{print$1}')
381
+
piholeDNS2=$(echo $piholeDNS| sed 's/[, \t]\+/,/g'| awk -F, '{print$2}')
382
+
383
+
if! valid_ip $piholeDNS1|| [ !$piholeDNS1 ];then
384
+
piholeDNS1=$strInvalid
385
+
fi
386
+
387
+
if! valid_ip $piholeDNS2&& [ $piholeDNS2 ];then
388
+
piholeDNS2=$strInvalid
389
+
fi
390
+
391
+
else
392
+
echo"::: Cancel selected, exiting...."
393
+
exit 1
394
+
fi
395
+
396
+
if [[ $piholeDNS1==$strInvalid ]] || [[ $piholeDNS2==$strInvalid ]];then
397
+
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
398
+
399
+
if [[ $piholeDNS1==$strInvalid ]];then
400
+
piholeDNS1=""
401
+
fi
402
+
403
+
if [[ $piholeDNS2==$strInvalid ]];then
404
+
piholeDNS2=""
405
+
fi
406
+
407
+
DNSSettingsCorrect=False
408
+
else
409
+
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
410
+
DNSSettingsCorrect=True
411
+
else
412
+
# If the settings are wrong, the loop continues
413
+
DNSSettingsCorrect=False
414
+
fi
415
+
fi
416
+
done
417
+
;;
319
418
esac
320
419
else
321
420
echo"::: Cancel selected. Exiting..."
@@ -356,8 +455,16 @@ versionCheckDNSmasq(){
356
455
$SUDO cp $newFileToInstall$newFileFinalLocation
357
456
echo" done."
358
457
$SUDO sed -i "s/@INT@/$piholeInterface/"$newFileFinalLocation
359
-
$SUDO sed -i "s/@DNS1@/$piholeDNS1/"$newFileFinalLocation
360
-
$SUDO sed -i "s/@DNS2@/$piholeDNS2/"$newFileFinalLocation
458
+
if [[ "$piholeDNS1"!="" ]];then
459
+
$SUDO sed -i "s/@DNS1@/$piholeDNS1/"$newFileFinalLocation
460
+
else
461
+
$SUDO sed -i '/^server=@DNS1@/d'$newFileFinalLocation
462
+
fi
463
+
if [[ "$piholeDNS2"!="" ]];then
464
+
$SUDO sed -i "s/@DNS2@/$piholeDNS2/"$newFileFinalLocation
465
+
else
466
+
$SUDO sed -i '/^server=@DNS2@/d'$newFileFinalLocation
467
+
fi
361
468
}
362
469
363
470
installScripts() {
@@ -387,7 +494,7 @@ stopServices() {
387
494
# Stop dnsmasq and lighttpd
388
495
$SUDOecho":::"
389
496
$SUDOecho -n "::: Stopping services..."
390
-
$SUDO service dnsmasq stop & spinner $!||true
497
+
#$SUDO service dnsmasq stop & spinner $! || true
391
498
$SUDO service lighttpd stop & spinner $!||true
392
499
$SUDOecho" done."
393
500
}
@@ -540,21 +647,31 @@ runGravity() {
540
647
/usr/local/bin/gravity.sh
541
648
}
542
649
650
+
setUser(){
651
+
# Check if user pihole exists and create if not
652
+
echo"::: Checking if user 'pihole' exists..."
653
+
if id -u pihole > /dev/null 2>&1;then
654
+
echo"::: User 'pihole' already exists"
655
+
else
656
+
echo"::: User 'pihole' doesn't exist. Creating..."
0 commit comments