From 123494c484ce380f35a6e54d9da68eeaf9f62b8f Mon Sep 17 00:00:00 2001 From: ronivay Date: Mon, 1 Jun 2020 09:23:25 +0300 Subject: [PATCH] Add free disk space check and prompts if disk space or memory amount is not enough --- xo-install.sh | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/xo-install.sh b/xo-install.sh index cb34236..255b5b6 100755 --- a/xo-install.sh +++ b/xo-install.sh @@ -835,14 +835,48 @@ function CheckCertificate { function CheckMemory { SYSMEM=$(grep MemTotal /proc/meminfo | awk '{print $2}') - if [[ $SYSMEM < 3000000 ]]; then + if [[ $SYSMEM -lt 3000000 ]]; then echo - echo -e "${COLOR_RED}WARNING: you have less than 3GB of RAM in your system. Installation might run out of memory${COLOR_N}" - echo + echo -e "${COLOR_RED}WARNING: you have less than 3GB of RAM in your system. Installation might run out of memory, continue anyway?${COLOR_N}" + echo + read -p "y/N: " answer + case $answer in + y) + : + ;; + n) + exit 0 + ;; + *) + exit 0 + ;; + esac fi } +function CheckDiskFree { + FREEDISK=$(df -P -k ${INSTALLDIR%/*} | tail -1 | awk '{print $4}') + + if [[ $FREEDISK -lt 1048576 ]]; then + echo + echo -e "${COLOR_RED}free disk space in ${INSTALLDIR%/*} seems to be less than 1GB. Install/update will most likely fail, continue anyway?${COLOR_N}" + echo + read -p "y/N: " answer + case $answer in + y) + : + ;; + n) + exit 0 + ;; + *) + exit 0 + ;; + esac + fi +} + function PullDockerImage { echo