2020-04-22 16:04:49 +02:00
#!/bin/bash
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
2022-05-29 12:45:09 +02:00
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
2020-05-17 15:56:54 +02:00
source ../settings/scripts/_common.sh
2020-04-22 16:04:49 +02:00
source /usr/share/yunohost/helpers
#=================================================
2024-02-29 10:33:15 +01:00
# REINSTALL DEPENDENCIES
2020-05-17 15:56:54 +02:00
#=================================================
2024-08-30 22:47:53 +02:00
ynh_script_progression "Reinstalling Ruby..."
ynh_ruby_install
2020-12-18 22:56:28 +01:00
2024-08-30 22:47:53 +02:00
ynh_script_progression "Reinstalling NodeJS..."
ynh_nodejs_install
2020-05-17 15:56:54 +02:00
#=================================================
2022-05-29 12:45:09 +02:00
# RESTORE THE APP MAIN DIR
2020-05-17 15:56:54 +02:00
#=================================================
2024-08-30 22:47:53 +02:00
ynh_script_progression "Restoring the app main directory..."
2022-05-29 12:45:09 +02:00
2024-08-30 22:47:53 +02:00
ynh_restore "$install_dir"
2022-09-26 02:56:12 +02:00
2024-08-30 22:47:53 +02:00
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:www-data" "$install_dir"
2020-05-17 15:56:54 +02:00
#=================================================
2022-05-29 12:45:09 +02:00
# RESTORE THE POSTGRESQL DATABASE
2020-05-17 15:56:54 +02:00
#=================================================
2024-08-30 22:47:53 +02:00
ynh_script_progression "Restoring the PostgreSQL database..."
2020-05-17 15:56:54 +02:00
2024-08-30 22:47:53 +02:00
ynh_psql_db_shell < ./db.sql
2020-05-17 15:56:54 +02:00
#=================================================
2022-05-29 12:45:09 +02:00
# BUILD APP
2020-05-17 15:56:54 +02:00
#=================================================
2024-08-30 22:47:53 +02:00
ynh_script_progression "Building app..."
2022-05-29 12:45:09 +02:00
2024-02-29 10:33:15 +01:00
pushd "$install_dir/live"
2024-08-30 22:47:53 +02:00
gem install "bundler:$bundler_version"
ynh_exec_as_app ruby_load_path" "$ld_preload" script/configure_bundler
2022-05-29 12:45:09 +02:00
popd
2020-05-17 15:56:54 +02:00
#=================================================
2024-02-29 10:33:15 +01:00
# RESTORE SYSTEM CONFIGURATIONS
2020-05-17 15:56:54 +02:00
#=================================================
2024-08-30 22:47:53 +02:00
ynh_script_progression "Restoring system configurations related to $app..."
2024-02-29 10:33:15 +01:00
2024-08-30 22:47:53 +02:00
ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf"
2022-05-29 12:45:09 +02:00
2024-08-30 22:47:53 +02:00
ynh_restore "/etc/systemd/system/${app}_web.service"
ynh_restore "/etc/systemd/system/${app}_sidekiq.service"
ynh_restore "/etc/systemd/system/${app}.target"
2022-06-07 23:23:47 +02:00
systemctl enable "${app}_web" "${app}_sidekiq" "$app.target" --quiet
2024-02-29 10:33:15 +01:00
yunohost service add "$app.target" --description "Diaspora service (unicorn web and sidekiq)" \
--log "$install_dir/live/log/production.log" \
"$install_dir/live/log/unicorn-stderr.log" \
"$install_dir/live/log/unicorn-stdout.log" \
"$install_dir/live/log/sidekiq.log"
2020-05-17 15:56:54 +02:00
2024-08-30 22:47:53 +02:00
ynh_restore "/etc/tmpfiles.d/${app}.conf"
2024-02-29 10:33:15 +01:00
systemd-tmpfiles --create
2020-05-17 15:56:54 +02:00
#=================================================
2024-02-29 10:33:15 +01:00
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
2020-05-17 15:56:54 +02:00
#=================================================
2024-08-30 22:47:53 +02:00
ynh_script_progression "Reloading NGINX web server and $app's service..."
2020-05-17 15:56:54 +02:00
2024-02-29 10:33:15 +01:00
systemctl restart "${app}.target"
2024-08-30 22:47:53 +02:00
ynh_systemctl --service="${app}_web.service" --action=restart --log_path="$install_dir/live/log/production.log" --wait_until="successfully configured the federation library"
ynh_systemctl --service="${app}_sidekiq.service" --action=restart --log_path="systemd" --wait_until="Running in ruby"
2020-12-18 22:56:28 +01:00
2024-08-30 22:47:53 +02:00
ynh_systemctl --service=nginx --action=reload
2020-05-17 15:56:54 +02:00
2022-05-29 12:45:09 +02:00
#=================================================
# END OF SCRIPT
#=================================================
2024-08-30 22:47:53 +02:00
ynh_script_progression "Restoration completed for $app"