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

feat: Validate configured RAM (#683)

parent 56c6a451
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -55,12 +55,14 @@ 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."
      [[ "${FS,,}" != "zfs" ]] && warn "$msg" || info "$msg"
    fi
  fi

fi
+4 −5
Original line number Diff line number Diff line
@@ -139,13 +139,12 @@ if [[ "${BOOT_MODE:-}" == "windows"* ]]; then
  fi
fi

# Check memory

[[ "${FS,,}" == "zfs" ]] && RAM_CHECK="N"
# Check available memory

if [[ "$RAM_CHECK" != [Nn]* ]] && (( (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
  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

# Helper functions