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-02-29 10:33:15 +01:00
|
|
|
ynh_script_progression --message="Reinstalling Ruby..." --weight=5
|
|
|
|
ynh_exec_warn_less ynh_install_ruby --ruby_version="$ruby_version"
|
2020-12-18 22:56:28 +01:00
|
|
|
|
2024-02-29 10:33:15 +01:00
|
|
|
ynh_script_progression --message="Reinstalling NodeJS..." --weight=5
|
|
|
|
ynh_exec_warn_less ynh_install_nodejs --nodejs_version="$nodejs_version"
|
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
|
|
|
#=================================================
|
2022-09-26 02:56:12 +02:00
|
|
|
ynh_script_progression --message="Restoring the app main directory..." --weight=1
|
2022-05-29 12:45:09 +02:00
|
|
|
|
2024-02-29 10:11:40 +01:00
|
|
|
ynh_restore_file --origin_path="$install_dir"
|
2022-05-29 12:45:09 +02:00
|
|
|
|
2024-02-29 10:11:40 +01:00
|
|
|
chmod -R o-rwx "$install_dir"
|
2024-02-29 10:33:15 +01:00
|
|
|
chown -R "$app:www-data" "$install_dir"
|
2022-09-26 02:56:12 +02:00
|
|
|
|
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-02-29 10:33:15 +01:00
|
|
|
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1
|
2020-05-17 15:56:54 +02:00
|
|
|
|
2024-02-29 10:33:15 +01:00
|
|
|
ynh_psql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./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
|
|
|
#=================================================
|
2022-05-29 12:45:09 +02:00
|
|
|
ynh_script_progression --message="Building app..." --weight=40
|
|
|
|
|
2024-02-29 10:33:15 +01:00
|
|
|
pushd "$install_dir/live"
|
2022-05-29 12:45:09 +02:00
|
|
|
ynh_use_ruby
|
|
|
|
ynh_use_nodejs
|
2024-02-29 10:33:15 +01:00
|
|
|
ynh_gem install "bundler:$bundler_version"
|
|
|
|
ynh_exec_as "$app" "$ynh_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-02-29 10:33:15 +01:00
|
|
|
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
|
|
|
|
|
|
|
|
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
2022-05-29 12:45:09 +02:00
|
|
|
|
2022-05-29 12:57:08 +02:00
|
|
|
ynh_restore_file --origin_path="/etc/systemd/system/${app}_web.service"
|
|
|
|
ynh_restore_file --origin_path="/etc/systemd/system/${app}_sidekiq.service"
|
2024-02-29 10:33:15 +01:00
|
|
|
ynh_restore_file --origin_path="/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-02-29 10:33:15 +01:00
|
|
|
ynh_restore_file --origin_path="/etc/tmpfiles.d/${app}.conf"
|
|
|
|
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-02-29 10:33:15 +01:00
|
|
|
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
|
2020-05-17 15:56:54 +02:00
|
|
|
|
2024-02-29 10:33:15 +01:00
|
|
|
systemctl restart "${app}.target"
|
|
|
|
ynh_systemd_action --service_name="${app}_web.service" --action=restart --log_path="$install_dir/live/log/production.log" --line_match="successfully configured the federation library"
|
|
|
|
ynh_systemd_action --service_name="${app}_sidekiq.service" --action=restart --log_path="systemd" --line_match="Running in ruby"
|
2020-12-18 22:56:28 +01:00
|
|
|
|
2022-05-29 12:45:09 +02:00
|
|
|
ynh_systemd_action --service_name=nginx --action=reload
|
2020-05-17 15:56:54 +02:00
|
|
|
|
2022-05-29 12:45:09 +02:00
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2022-09-26 02:56:12 +02:00
|
|
|
ynh_script_progression --message="Restoration completed for $app" --last
|