Unverified Commit 36af9a34 authored by Kroese's avatar Kroese Committed by GitHub
Browse files

feat: Validate configured RAM (#924)

parent 5e6f9314
Loading
Loading
Loading
Loading
+12 −6
Original line number Diff line number Diff line
@@ -20,12 +20,18 @@ if [[ "$RAM_CHECK" != [Nn]* ]]; then
  AVAIL_GB=$(( RAM_AVAIL/1073741824 ))

  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."
    exit 17
  fi

    msg="Your configured RAM_SIZE of $WANTED_GB GB is too high for the $AVAIL_GB GB of memory available, please set a lower value."
    [[ "${FS,,}" != "zfs" ]] && error "$msg" && exit 17
    info "$msg"
  else
    if (( (RAM_WANTED + (RAM_SPARE * 3)) > RAM_AVAIL )); then
    warn "your configured RAM_SIZE of $WANTED_GB GB is very close to the $AVAIL_GB GB of memory available, please consider a lower value."
      msg="your configured RAM_SIZE of $WANTED_GB GB is very close to the $AVAIL_GB GB of memory available, please consider a lower value."
      if [[ "${FS,,}" != "zfs" ]]; then
        warn "$msg"
      else
        info "$msg"
      fi
    fi
  fi

fi
+5 −8
Original line number Diff line number Diff line
@@ -132,15 +132,12 @@ SPACE_GB=$(( (SPACE + 1073741823)/1073741824 ))
echo "❯ CPU: ${CPU} | RAM: $AVAIL_GB/$TOTAL_GB GB | DISK: $SPACE_GB GB (${FS}) | KERNEL: ${SYS}..."
echo

# Check memory
# Check available 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."
    exit 17
  fi
if [[ "$RAM_CHECK" != [Nn]* ]] && (( (RAM_WANTED + RAM_SPARE) > RAM_AVAIL )); then
  msg="Your configured RAM_SIZE of $WANTED_GB GB is too high for the $AVAIL_GB GB of memory available, please set a lower value."
  [[ "${FS,,}" != "zfs" ]] && error "$msg" && exit 17
  info "$msg"
fi

# Cleanup files