From 108f98b6da06e4df4d247095f92eb38e12b6412c Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 20 Jun 2017 14:09:42 +0100 Subject: [PATCH] Check RAM availability before install of matrix --- src/freedombone-app-etherpad | 7 +------ src/freedombone-app-matrix | 2 ++ src/freedombone-utils-setup | 11 +++++++++++ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/freedombone-app-etherpad b/src/freedombone-app-etherpad index bae5a0f0..8ba4ccd8 100755 --- a/src/freedombone-app-etherpad +++ b/src/freedombone-app-etherpad @@ -452,12 +452,7 @@ function install_etherpad { exit 7359 fi - # Check the amount of RAM - ram_available=$(grep MemTotal /proc/meminfo | awk '{print $2}') - if [ $ram_available -lt 2000000 ]; then - echo $'Need at least 2GB RAM to install etherpad' - exit 783524 - fi + check_ram_availability 2 if [ -f $IMAGE_PASSWORD_FILE ]; then ETHERPAD_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)" diff --git a/src/freedombone-app-matrix b/src/freedombone-app-matrix index 56cd7175..938e1c07 100755 --- a/src/freedombone-app-matrix +++ b/src/freedombone-app-matrix @@ -621,6 +621,8 @@ function install_home_server { } function install_matrix { + check_ram_availability 1.5 + if [ ! -d $INSTALL_DIR ]; then mkdir -p $INSTALL_DIR fi diff --git a/src/freedombone-utils-setup b/src/freedombone-utils-setup index f31fadc7..d98c94c1 100755 --- a/src/freedombone-utils-setup +++ b/src/freedombone-utils-setup @@ -1028,4 +1028,15 @@ function combine_all_scripts { done } +function check_ram_availability { + minimum_ram_gb="$1" + minimum_ram_bytes=$((minimum_ram_gb * 1024 * 1024)) + + ram_available=$(grep MemTotal /proc/meminfo | awk '{print $2}') + if [ $ram_available -lt $minimum_ram_bytes ]; then + echo $"Need at least ${minimum_ram_gb}GB RAM to install this app" + exit 783524 + fi +} + # NOTE: deliberately no exit 0