From 54224caaee67b90a0e611027c815af11cad304c6 Mon Sep 17 00:00:00 2001 From: rosbeef andino Date: Fri, 16 Dec 2022 18:57:50 +0000 Subject: [PATCH] Update restore --- scripts/restore | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/scripts/restore b/scripts/restore index be0e019..ae926e5 100644 --- a/scripts/restore +++ b/scripts/restore @@ -98,19 +98,26 @@ ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name" #================================================= # ADD SWAP IF NEEDED #================================================= -ynh_script_progression --message="Adding swap if needed..." --weight=1 -total_memory=$(ynh_get_ram --total) -swap_needed=0 +if [ -n "$(grep 'kthreadd' /proc/2/status 2>/dev/null)" ]; then -if [ $total_memory -lt $memory_needed ]; then - # Need a minimum of 8Go of memory - swap_needed=$(($memory_needed - $total_memory)) + ynh_script_progression --message="Adding swap if needed..." --weight=1 + + total_memory=$(ynh_get_ram --total) + swap_needed=0 + + if [ $total_memory -lt $memory_needed ]; then + # Need a minimum of 8Go of memory + swap_needed=$(($memory_needed - $total_memory)) + ynh_script_progression --message="Adding $swap_needed Mo to swap..." --weight=1 + ynh_add_swap --size=$swap_needed + + 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 -ynh_script_progression --message="Adding $swap_needed Mo to swap..." --weight=1 -ynh_add_swap --size=$swap_needed - #================================================= # BUILD APP #=================================================