diff options
Diffstat (limited to 'scripts/restore')
| -rw-r--r-- | scripts/restore | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/scripts/restore b/scripts/restore index 59e71fc..c6e4bc8 100644 --- a/scripts/restore +++ b/scripts/restore @@ -8,13 +8,16 @@ #Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh -source ../settings/scripts/ynh_install_ruby +source ../settings/scripts/ynh_install_ruby__2 source ../settings/scripts/ynh_add_extra_apt_repos__3 +source ../settings/scripts/ynh_add_swap +source ../settings/scripts/ynh_check_ram source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= +ynh_script_progression --message="Managing script failure..." --weight=2 ynh_clean_setup () { ynh_clean_check_starting @@ -81,11 +84,28 @@ chown -R $app: $final_path #================================================= # SPECIFIC RESTORATION #================================================= +# ADD SWAP IF NEEDED +#================================================= +ynh_script_progression --message="Adding swap if needed..." --weight=4 + +total_memory=$(ynh_check_ram) +total_swap=$(ynh_check_ram --only_swap) +swap_needed=0 + +if [ $total_memory -lt 2560 ]; then + # Need a minimum of 8Go of memory + swap_needed=$((2560 - $total_memory)) +fi + +ynh_script_progression --message="Adding $swap_needed Mo to swap..." --weight=1 +ynh_add_swap --size=$swap_needed + +#================================================= # REINSTALL DEPENDENCIES #================================================= ynh_script_progression --message="Reinstalling dependencies..." --weight=63 -ynh_install_nodejs --nodejs_version="8" +ynh_install_nodejs --nodejs_version="10" ynh_install_app_dependencies $pkg_dependencies ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" @@ -94,8 +114,9 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st #================================================= ynh_script_progression --message="Installing Ruby..." --weight=393 -ynh_install_ruby --ruby_version=2.6.1 -/opt/rbenv/versions/2.6.1/bin/gem update --system +ynh_install_ruby --ruby_version=2.6.5 +/opt/rbenv/versions/2.6.5/bin/gem update --system +/opt/rbenv/versions/2.6.5/bin/gem install bundler:1.17.3 --no-document #================================================= # RESTORE THE POSTGRESQL DATABASE @@ -104,6 +125,7 @@ ynh_script_progression --message="Restoring the PostgreSQL database..." --weight ynh_psql_test_if_first_run ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd +ynh_psql_execute_as_root --sql="ALTER USER $db_user CREATEDB;" ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name" #================================================= @@ -117,9 +139,9 @@ ynh_restore_file --origin_path="/etc/systemd/system/$app-streaming.service" systemctl enable "$app-web" "$app-sidekiq" "$app-streaming" #================================================= -# ADVERTISE SERVICE IN ADMIN PANEL +# INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Advertising service in admin panel..." --weight=3 +ynh_script_progression --message="Integrating service in YunoHost..." --weight=3 yunohost service add $app-web yunohost service add $app-sidekiq |
