Fourdee - See notes:

https://github.com/pi-hole/pi-hole/issues/602
+ Improve available free disk space check.
+ Option to override if the free disk space check is not a valid
integer.
This commit is contained in:
Daniel (Fourdee) 2016-08-12 12:44:45 +01:00
parent 7e5bcd2ec3
commit a9a499939e

View file

@ -155,20 +155,35 @@ In the next section, you can choose to use your current network settings (DHCP)
verifyFreeDiskSpace() { verifyFreeDiskSpace() {
# 50MB is the minimum space needed (45MB install (includes web admin bootstrap/jquery libraries etc) + 5MB one day of logs.)
requiredFreeBytes=51200
existingFreeBytes=$(df -lk / 2>&1 | awk '{print $4}' | head -2 | tail -1) # 50MB is the minimum space needed (45MB install (includes web admin bootstrap/jquery libraries etc) + 5MB one day of logs.)
# - Fourdee: Local ensures the variable is only created, and accessible within this function/void. Generally considered a "good" coding practice for non-global variables.
local requiredFreeBytes=51200
local existingFreeBytes=$(df -Pk | grep -m1 '\/$' | awk '{print $4}')
# - Unknown free disk space , not a integer
if ! [[ "$existingFreeBytes" =~ ^([0-9])+$ ]]; then if ! [[ "$existingFreeBytes" =~ ^([0-9])+$ ]]; then
existingFreeBytes=$(df -lk /dev 2>&1 | awk '{print $4}' | head -2 | tail -1)
whiptail --title "Unknown free disk space" --yesno "We were unable to determine available free disk space on this system.\n\nYou may override this check and force the installation, however, it is not recommended.\n\nWould you like to continue with the installation?" --defaultno --backtitle "Pi-hole" $r $c
local choice=$?
if (( $choice != 0 )); then
echo "non-integer value from existingFreeBytes ($existingFreeBytes)"
echo "Unknown free space, user aborted, exiting..."
exit
fi fi
if [[ $existingFreeBytes -lt $requiredFreeBytes ]]; then # - Insufficient free disk space
elif [[ $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 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 "$existingFreeBytes is less than $requiredFreeBytes"
echo "Insufficient free space, exiting..." echo "Insufficient free space, exiting..."
exit 1 exit 1
fi fi
} }