Compare commits

...

2 Commits

Author SHA1 Message Date
Kroese
92b4bfc383
feat: Validate configured RAM (#920)
Some checks are pending
Build / Check (push) Waiting to run
Build / Build (push) Blocked by required conditions
2025-03-13 11:35:08 +01:00
Kroese
092ed23085
feat: Check CPU core configuration (#919) 2025-03-13 10:47:25 +01:00

View File

@ -17,7 +17,6 @@ echo " For support visit $SUPPORT"
: "${TZ:=""}" # System local timezone
: "${DEBUG:="N"}" # Disable debugging mode
: "${COMMIT:="N"}" # Commit to local image
: "${COUNTRY:=""}" # Country code for mirror
: "${CONSOLE:="N"}" # Disable console mode
: "${ALLOCATE:=""}" # Preallocate diskspace
@ -75,6 +74,7 @@ CPU="${CPU// with Radeon Graphics/}"
CPU="${CPU// with Radeon Vega Graphics/}"
[ -z "${CPU// /}" ] && CPU="Unknown"
[[ -n ${CPU_CORES//[0-9]} ]] && error "Invalid amount of CPU_CORES: $CPU_CORES" && exit 15
# Check system
@ -86,13 +86,13 @@ fi
# Check folder
if [[ "$COMMIT" != [Nn]* ]]; then
if [[ "${COMMIT:-}" == [Yy1]* ]]; then
STORAGE="/local"
mkdir -p "$STORAGE"
else
if [ ! -d "$STORAGE" ]; then
error "Storage folder ($STORAGE) not found!" && exit 13
fi
fi
if [ ! -d "$STORAGE" ]; then
error "Storage folder ($STORAGE) not found!" && exit 13
fi
# Check filesystem
@ -107,9 +107,13 @@ 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 15
! 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
@ -130,6 +134,8 @@ echo
# Check memory
[[ "${FS,,}" == "zfs" ]] && RAM_CHECK="N"
if [[ "$RAM_CHECK" != [Nn]* ]]; then
if (( (RAM_WANTED + RAM_SPARE) > RAM_AVAIL )); then
error "Your configured RAM_SIZE of $WANTED_GB GB is too high for the $AVAIL_GB GB of memory available, please set a lower value."