Skip to content

Commit

Permalink
swap check
Browse files Browse the repository at this point in the history
Now we check if enough disk space is available before creating SWAP.
  • Loading branch information
QROkes committed Mar 22, 2022
1 parent 176806a commit 596fd44
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/install
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,15 @@ swap_create() {
local newswap="0"
fi

# Check if disk available space is enough!
local avail=$(df -hBG --output=avail / | grep -Eo "[0-9]+" | head -n 1)
if [[ -n $avail && -n $newswap && $(($newswap+1)) -ge $avail ]]; then
echo "${red}[ERROR] No disk space available for SWAP!${dim} (Needed: ${newswap}Gb Available: ${avail}Gb ) ${end}"
local newswap="0"
else
echo "${blu}${dim}Swap size: ${newswap}Gb (Available: ${avail}Gb) ${end}"
fi

if [[ -z $newswap || $newswap == 0 ]]; then
echo "${red}[ERROR] Webinoly could not create a new SWAP file! ${end}"
else
Expand Down

0 comments on commit 596fd44

Please sign in to comment.