aboutsummaryrefslogtreecommitdiff
path: root/scripts/restore
diff options
context:
space:
mode:
authoryalh76 <yalh@yahoo.com>2020-03-29 21:56:56 +0200
committeryalh76 <yalh@yahoo.com>2020-03-29 21:56:56 +0200
commit64149e99b7b28f76f6cc25607637692610cb1bd6 (patch)
tree2cfceadeceae634791a7fb207268b5943f3e0f5e /scripts/restore
parent25a20b1d17f0b8752a39259c3b73a451e203255d (diff)
parentbf0dea0f437c00db213c27da299a0dda65810d6a (diff)
downloadmastodon_ynh-64149e99b7b28f76f6cc25607637692610cb1bd6.tar.gz
mastodon_ynh-64149e99b7b28f76f6cc25607637692610cb1bd6.tar.bz2
mastodon_ynh-64149e99b7b28f76f6cc25607637692610cb1bd6.zip
Merge branch 'testing' into ldap
Diffstat (limited to 'scripts/restore')
-rw-r--r--scripts/restore34
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