check available disk/memory every time and prompt or just print warning depending on how script was started
This commit is contained in:
@@ -989,10 +989,12 @@ function CheckMemory {
|
|||||||
SYSMEM=$(runcmd_stdout "grep MemTotal /proc/meminfo | awk '{print \$2}'")
|
SYSMEM=$(runcmd_stdout "grep MemTotal /proc/meminfo | awk '{print \$2}'")
|
||||||
|
|
||||||
if [[ "$SYSMEM" -lt 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 -e "${COLOR_RED}WARNING: you have less than 3GB of RAM in your system. Installation might run out of memory, continue anyway?${COLOR_N}"
|
# no prompt when running non interactive options
|
||||||
echo
|
if [[ "$INTERACTIVE" == "false" ]]; then
|
||||||
read -r -p "y/N: " answer
|
return 0
|
||||||
|
fi
|
||||||
|
read -r -p "continue anyway? y/N: " answer
|
||||||
case $answer in
|
case $answer in
|
||||||
y)
|
y)
|
||||||
:
|
:
|
||||||
@@ -1013,10 +1015,12 @@ function CheckDiskFree {
|
|||||||
FREEDISK=$(runcmd_stdout "df -P -k '${INSTALLDIR%/*}' | tail -1 | awk '{print \$4}'")
|
FREEDISK=$(runcmd_stdout "df -P -k '${INSTALLDIR%/*}' | tail -1 | awk '{print \$4}'")
|
||||||
|
|
||||||
if [[ "$FREEDISK" -lt 1048576 ]]; then
|
if [[ "$FREEDISK" -lt 1048576 ]]; then
|
||||||
echo
|
echo -e "${COLOR_RED}WARNING: free disk space in ${INSTALLDIR%/*} seems to be less than 1GB. Install/update will most likely fail${COLOR_N}"
|
||||||
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}"
|
# no prompt when running non interactive options
|
||||||
echo
|
if [[ "$INTERACTIVE" == "false" ]]; then
|
||||||
read -r -p "y/N: " answer
|
return 0
|
||||||
|
fi
|
||||||
|
read -r -p "continue anyway? y/N: " answer
|
||||||
case $answer in
|
case $answer in
|
||||||
y)
|
y)
|
||||||
:
|
:
|
||||||
@@ -1091,14 +1095,12 @@ read -r -p ": " option
|
|||||||
|
|
||||||
if [ "$PKG_FORMAT" == "rpm" ]; then
|
if [ "$PKG_FORMAT" == "rpm" ]; then
|
||||||
TASK="Installation"
|
TASK="Installation"
|
||||||
INTERACTIVE="true"
|
|
||||||
InstallDependenciesRPM
|
InstallDependenciesRPM
|
||||||
InstallXO
|
InstallXO
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
if [ "$PKG_FORMAT" == "deb" ]; then
|
if [ "$PKG_FORMAT" == "deb" ]; then
|
||||||
TASK="Installation"
|
TASK="Installation"
|
||||||
INTERACTIVE="true"
|
|
||||||
InstallDependenciesDeb
|
InstallDependenciesDeb
|
||||||
InstallXO
|
InstallXO
|
||||||
exit 0
|
exit 0
|
||||||
@@ -1106,7 +1108,6 @@ read -r -p ": " option
|
|||||||
;;
|
;;
|
||||||
2)
|
2)
|
||||||
TASK="Update"
|
TASK="Update"
|
||||||
INTERACTIVE="true"
|
|
||||||
UpdateNodeYarn
|
UpdateNodeYarn
|
||||||
UpdateXO
|
UpdateXO
|
||||||
exit 0
|
exit 0
|
||||||
@@ -1127,6 +1128,12 @@ esac
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# if no arguments given, we assume interactive mode.
|
||||||
|
# set here because some of the following checks either prompt user input or not.
|
||||||
|
if [[ $# == "0" ]]; then
|
||||||
|
INTERACTIVE="true"
|
||||||
|
fi
|
||||||
|
|
||||||
# these functions check specific requirements and are run everytime
|
# these functions check specific requirements and are run everytime
|
||||||
scriptInfo
|
scriptInfo
|
||||||
CheckUser
|
CheckUser
|
||||||
@@ -1135,14 +1142,16 @@ CheckXE
|
|||||||
CheckOS
|
CheckOS
|
||||||
CheckSystemd
|
CheckSystemd
|
||||||
CheckCertificate
|
CheckCertificate
|
||||||
|
# skip disk/memory check when using rollback as nothing new installed
|
||||||
|
if [[ "$1" != "--rollback" ]]; then
|
||||||
|
CheckDiskFree
|
||||||
|
CheckMemory
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ $# != "0" ]]; then
|
if [[ $# != "0" ]]; then
|
||||||
HandleArgs "$@"
|
HandleArgs "$@"
|
||||||
exit 0
|
exit 0
|
||||||
else
|
else
|
||||||
# we only want to execute disk/memory functions when non-interactive args given as they might prompt for user input
|
|
||||||
CheckDiskFree
|
|
||||||
CheckMemory
|
|
||||||
# menu starts only when no args given
|
# menu starts only when no args given
|
||||||
StartUpScreen
|
StartUpScreen
|
||||||
fi
|
fi
|
||||||
|
Reference in New Issue
Block a user