From 87f82addbc2e7aa712802e356c366edcd6c7c6c4 Mon Sep 17 00:00:00 2001 From: Joshua Tauberer Date: Sun, 11 Jan 2015 14:09:21 +0000 Subject: [PATCH] preflight memory check: units problems /proc/meminfo reports kibibytes. Lower the minimum memory requirement so that 768 MB (not MiB) also is allowed. Report the detected memory in MB (not KiB), to be clearer. Fixes #289. --- setup/preflight.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/setup/preflight.sh b/setup/preflight.sh index be584221..90d36cc1 100644 --- a/setup/preflight.sh +++ b/setup/preflight.sh @@ -17,13 +17,19 @@ if [ "`lsb_release -d | sed 's/.*:\s*//' | sed 's/14\.04\.[0-9]/14.04/' `" != "U exit fi -# Check that we have enough memory. Skip the check if we appear to be -# running inside of Vagrant, because that's really just for testing. +# Check that we have enough memory. +# +# /proc/meminfo reports free memory in kibibytes. Our baseline will be 768 KB, +# which is 750000 kibibytes. +# +# Skip the check if we appear to be running inside of Vagrant, because that's really just for testing. TOTAL_PHYSICAL_MEM=$(head -n 1 /proc/meminfo | awk '{print $2}') -if [ $TOTAL_PHYSICAL_MEM -lt 786432 ]; then +if [ $TOTAL_PHYSICAL_MEM -lt 750000 ]; then if [ ! -d /vagrant ]; then - echo "Your Mail-in-a-Box needs more than $TOTAL_PHYSICAL_MEM MB RAM." + TOTAL_PHYSICAL_MEM=$(expr \( \( $TOTAL_PHYSICAL_MEM \* 1024 \) / 1000 \) / 1000) + echo "Your Mail-in-a-Box needs more memory (RAM) to function properly." echo "Please provision a machine with at least 768 MB, 1 GB recommended." + echo "This machine has $TOTAL_PHYSICAL_MEM MB memory." exit fi fi