1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/discourse_ynh.git synced 2024-09-03 18:26:18 +02:00
discourse_ynh/scripts/restore

82 lines
3.1 KiB
Text
Raw Normal View History

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
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
fi
2018-04-07 12:02:34 +02:00
#=================================================
2024-01-26 22:16:29 +01:00
# INSTALL DEPENDENCIES
#=================================================
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
#=================================================
2021-04-10 01:48:01 +02:00
# RESTORE THE APP MAIN DIR
#=================================================
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"
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..."
pushd "$install_dir/discourse"
2024-01-26 22:16:29 +01:00
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/discourse/log/unicorn.stderr.log" "$install_dir/discourse/log/unicorn.stdout.log" "$install_dir/discourse/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
ynh_systemd_action --service_name="$app" --action="start" --log_path="$install_dir/discourse/log/unicorn.stderr.log" --line_match="INFO -- : worker=$((unicorn_workers-1)) ready"
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"