浏览代码

Simplify RAM check

Use `docker info -f` to get the number of bytes. This results in fewer
dependencies on external programs, and better usage of Bash shell math.

Removes comment stemming from confusion about GiB vs GB.
Dan Church 2 年之前
父节点
当前提交
3c5bf1f6e6
共有 1 个文件被更改,包括 6 次插入3 次删除
  1. 6 3
      compose/bin/setup

+ 6 - 3
compose/bin/setup

@@ -1,9 +1,12 @@
 #!/bin/bash
 set -o errexit
 
-MEM=$(docker info | grep "Total Memory" | cut -d':' -f2 | xargs | sed s/GiB//)
-# Docker reports RAM 0.2 less than what it is actually set to
-(( $(echo "$MEM < 5.7" | bc -l) )) && echo "There must be at least 6GB of RAM allocated to Docker to continue." && exit
+MEM_BYTES=$(docker info -f '{{.MemTotal}}')
+MEM_MB=$(( MEM_BYTES / 1000000 ))
+(( MEM_MB >= 6000 )) || {
+  echo 'There must be at least 6GB of RAM allocated to Docker to continue.' >&2
+  exit 1
+}
 
 # shellcheck source=../env/db.env
 source env/db.env