Change check for linux memory (#452)
authorTodd Sharp <41924046+recursivecodes@users.noreply.github.com>
Mon, 28 Oct 2019 01:58:56 +0000 (21:58 -0400)
committerSam <sam.saffron@gmail.com>
Mon, 28 Oct 2019 01:58:56 +0000 (12:58 +1100)
* 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

index 205d4a0fb1ae5ba351365e7771f24e489f3118ca..c4daa6b9f62dcf48ff37211b6f277954d3e51fa4 100755 (executable)
@@ -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
 }
 
 ##