From a1ae93792a09ddb6eb16777ff6a76a2e177c293a Mon Sep 17 00:00:00 2001 From: rosbeef andino Date: Mon, 30 Jan 2023 00:52:44 +0000 Subject: [PATCH] Update upgrade --- scripts/upgrade | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index af1c45a..6f2efee 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -218,23 +218,22 @@ ynh_add_nginx_config # ADD SWAP IF NEEDED and not contenerized #================================================= -if [ -n "$(grep 'kthreadd' /proc/2/status 2>/dev/null)" ]; then +ynh_script_progression --message="Adding swap if needed..." --weight=1 - ynh_script_progression --message="Adding swap if needed..." --weight=1 +total_memory=$(ynh_get_ram --total) +swap_needed=0 - total_memory=$(ynh_get_ram --total) - swap_needed=0 - - if [ $total_memory -lt $memory_needed ]; then - # Need a minimum of memory +if [ $total_memory -lt $memory_needed ]; then + # Need a minimum of memory + if [ -n "$(grep 'kthreadd' /proc/2/status 2>/dev/null)" ]; then swap_needed=$(($memory_needed - $total_memory)) ynh_script_progression --message="Adding $swap_needed Mo to swap..." ynh_add_swap --size=$swap_needed + else + ynh_script_progression --message="No swap will be added as you are inside a container. Please take care of having more than 2,5G memory available..." fi - -else - ynh_script_progression --message="No swap will be added as you are inside a container. Please take care of having more than 2,5G memory available..." fi + #================================================= # BUILD APP #=================================================