From 20e812e3d8f37818aaaf9d5e2775cd45653c40c2 Mon Sep 17 00:00:00 2001
From: Todd Sharp <41924046+recursivecodes@users.noreply.github.com>
Date: Sun, 27 Oct 2019 21:58:56 -0400
Subject: [PATCH] Change check for linux memory (#452)

* Change check for linux memory

Some VMs clock in at *just under* 1GB, so checking for 1GB of RAM will miss these.  Instead, check for MB, divide by 1000 and round up.

* Refine the check_linux_memory function

Be a little more precise and only make an exception for VMs with >= 990MB RAM
---
 discourse-setup | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/discourse-setup b/discourse-setup
index 205d4a0..c4daa6b 100755
--- a/discourse-setup
+++ b/discourse-setup
@@ -114,7 +114,15 @@ check_osx_memory() {
 ## Linux available memory
 ##
 check_linux_memory() {
-  echo `free -g --si | awk ' /Mem:/  {print $2} '`
+  ## some VMs report just under 1GB of RAM, so
+  ## make an exception and allow those with more
+  ## than 989MB
+  mem=`free -m --si | awk ' /Mem:/ {print $2}'`
+  if [ "$mem" -ge 990 -a "$mem" -lt 1000 ]; then
+    echo 1
+  else
+    echo `free -g --si | awk ' /Mem:/  {print $2} '`
+  fi
 }
 
 ##
-- 
2.25.1