feat: Validate configured RAM

This commit is contained in:
Kroese 2025-03-13 11:25:38 +01:00 committed by GitHub
parent 092ed23085
commit 643f499347
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -107,8 +107,12 @@ fi
RAM_SPARE=500000000
RAM_AVAIL=$(free -b | grep -m 1 Mem: | awk '{print $7}')
RAM_TOTAL=$(free -b | grep -m 1 Mem: | awk '{print $2}')
if [[ -z ${RAM_SIZE//[0-9]} ]]; then
[ "$RAM_SIZE" -lt "130" ] && RAM_SIZE="${RAM_SIZE}G" || RAM_SIZE="${RAM_SIZE}M"
fi
RAM_SIZE=$(echo "${RAM_SIZE^^}" | sed 's/MB/M/g;s/GB/G/g;s/TB/T/g')
[[ -z ${RAM_SIZE//[0-9]} ]] && [ "$RAM_SIZE" -lt "130" ] && RAM_SIZE="${RAM_SIZE}G"
! numfmt --from=iec "$RAM_SIZE" &>/dev/null && error "Invalid RAM size: $RAM_SIZE" && exit 16
RAM_WANTED=$(numfmt --from=iec "$RAM_SIZE")
[ "$RAM_WANTED" -lt "136314880 " ] && error "Invalid RAM size: $RAM_SIZE" && exit 16