2018-04-07 12:02:34 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
2021-03-07 01:39:02 +01:00
|
|
|
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
2020-04-27 13:41:00 +02:00
|
|
|
source ../settings/scripts/_common.sh
|
2018-04-07 12:02:34 +02:00
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2024-01-26 22:16:29 +01:00
|
|
|
if [ "${PACKAGE_CHECK_EXEC:-0}" -ne 1 ]; then
|
|
|
|
# Check memory requirements
|
|
|
|
check_memory_requirements
|
2021-06-27 09:37:35 +02:00
|
|
|
fi
|
2018-04-30 18:53:20 +02:00
|
|
|
|
2018-04-07 12:02:34 +02:00
|
|
|
#=================================================
|
2024-01-26 22:16:29 +01:00
|
|
|
# INSTALL DEPENDENCIES
|
2020-04-27 13:41:00 +02:00
|
|
|
#=================================================
|
2024-01-26 22:16:29 +01:00
|
|
|
ynh_script_progression --message="Reinstalling Ruby..."
|
|
|
|
ynh_exec_warn_less ynh_install_ruby --ruby_version="$ruby_version"
|
|
|
|
ynh_use_ruby
|
2018-04-07 12:02:34 +02:00
|
|
|
|
2024-01-26 22:16:29 +01:00
|
|
|
ynh_script_progression --message="Reinstalling NodeJS..."
|
|
|
|
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
|
2018-04-07 12:02:34 +02:00
|
|
|
|
2020-04-27 13:41:00 +02:00
|
|
|
#=================================================
|
2021-04-10 01:48:01 +02:00
|
|
|
# RESTORE THE APP MAIN DIR
|
2020-04-27 13:41:00 +02:00
|
|
|
#=================================================
|
2021-04-10 01:48:01 +02:00
|
|
|
ynh_script_progression --message="Restoring the app main directory..."
|
|
|
|
|
2024-01-26 22:16:29 +01:00
|
|
|
ynh_restore_file --origin_path="$install_dir"
|
2020-04-27 13:41:00 +02:00
|
|
|
|
2024-01-26 22:16:29 +01:00
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R "$app:www-data" "$install_dir"
|
2022-07-19 00:04:56 +02:00
|
|
|
|
2018-04-07 12:02:34 +02:00
|
|
|
#=================================================
|
|
|
|
# RESTORE THE POSTGRESQL DATABASE
|
|
|
|
#=================================================
|
2024-01-26 22:16:29 +01:00
|
|
|
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1
|
|
|
|
|
|
|
|
ynh_psql_execute_as_root --database="$db_name" --sql="CREATE EXTENSION IF NOT EXISTS hstore;"
|
|
|
|
ynh_psql_execute_as_root --database="$db_name" --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;"
|
2018-04-07 12:02:34 +02:00
|
|
|
|
2024-01-26 22:16:29 +01:00
|
|
|
ynh_psql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./db.sql
|
2018-04-07 12:02:34 +02:00
|
|
|
|
2022-05-29 17:36:13 +02:00
|
|
|
#=================================================
|
|
|
|
# REINSTALL BUNDLE GEM
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Reinstall Bundle Gem..."
|
|
|
|
|
2024-01-26 22:16:29 +01:00
|
|
|
pushd "$install_dir"
|
|
|
|
ynh_gem install bundler
|
2022-05-29 17:36:13 +02:00
|
|
|
popd
|
|
|
|
|
2018-04-07 12:02:34 +02:00
|
|
|
#=================================================
|
2024-01-26 22:16:29 +01:00
|
|
|
# RESTORE SYSTEM CONFIGURATIONS
|
2018-04-07 12:02:34 +02:00
|
|
|
#=================================================
|
2024-01-26 22:16:29 +01:00
|
|
|
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
|
2018-04-07 12:02:34 +02:00
|
|
|
|
2024-01-26 22:16:29 +01:00
|
|
|
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
2018-04-07 12:02:34 +02:00
|
|
|
|
2024-01-26 22:16:29 +01:00
|
|
|
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
|
|
|
systemctl enable "$app.service" --quiet
|
|
|
|
yunohost service add "$app" --log "$install_dir/log/unicorn.stderr.log" "$install_dir/log/unicorn.stdout.log" "$install_dir/log/production.log"
|
2022-06-03 01:08:48 +02:00
|
|
|
|
|
|
|
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
|
|
|
|
2018-04-07 12:02:34 +02:00
|
|
|
#=================================================
|
2024-01-26 22:16:29 +01:00
|
|
|
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
|
2018-04-07 12:02:34 +02:00
|
|
|
#=================================================
|
2024-01-26 22:16:29 +01:00
|
|
|
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
|
2018-04-07 12:02:34 +02:00
|
|
|
|
2024-01-26 22:16:29 +01:00
|
|
|
ynh_systemd_action --service_name="$app" --action="start" --log_path="$install_dir/log/unicorn.stderr.log" --line_match="INFO -- : worker=$((unicorn_workers-1)) ready"
|
2020-04-27 13:41:00 +02:00
|
|
|
|
|
|
|
ynh_systemd_action --service_name=nginx --action=reload
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
2018-04-07 12:02:34 +02:00
|
|
|
|
2020-05-30 17:05:03 +02:00
|
|
|
ynh_script_progression --message="Restoration completed for $app"
|