1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/pgadmin_ynh.git synced 2024-09-03 19:56:38 +02:00
pgadmin_ynh/scripts/restore

83 lines
3.2 KiB
Text
Raw Normal View History

2017-11-14 16:05:26 +01:00
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
2022-03-13 15:22:35 +01:00
# IMPORT GENERIC HELPERS
#=================================================
2022-03-13 15:22:35 +01:00
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
2020-11-17 23:51:51 +01:00
source ../settings/scripts/experimental_helper.sh
source ../settings/scripts/_common.sh
2017-11-14 16:05:26 +01:00
source /usr/share/yunohost/helpers
2022-03-13 15:22:35 +01:00
#=================================================
2024-01-30 16:37:46 +01:00
# RESTORE THE APP MAIN DIR
2022-03-13 15:22:35 +01:00
#=================================================
2024-01-30 16:37:46 +01:00
ynh_script_progression --message="Restoring the app main directory..." --weight=1
2022-03-13 15:22:35 +01:00
2024-01-30 16:37:46 +01:00
ynh_restore_file --origin_path="$install_dir"
2022-03-13 15:22:35 +01:00
2024-01-30 16:37:46 +01:00
### $install_dir will automatically be initialized with some decent
### permissions by default ... however, you may need to recursively reapply
### ownership to all files such as after the ynh_setup_source step
chown -R "$app:www-data" "$install_dir"
2017-11-14 16:05:26 +01:00
2022-03-13 15:22:35 +01:00
#=================================================
2024-01-30 16:37:46 +01:00
# RESTORE THE POSTGRESQL SUPERUSER
2022-03-13 15:22:35 +01:00
#=================================================
2024-01-30 16:37:46 +01:00
ynh_script_progression --message="Restoring the Postgresql superuser..." --weight=1
password=$(cat hashed_password.txt)
ynh_psql_execute_as_root --sql "ALTER USER $app WITH PASSWORD '$password' SUPERUSER CREATEDB CREATEROLE REPLICATION"
2022-03-13 15:22:35 +01:00
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
2024-01-30 16:48:42 +01:00
ynh_script_progression --message="Updating python virtualenv..." --weight=5
2017-11-14 16:05:26 +01:00
2024-01-30 16:48:42 +01:00
ynh_install_venv
2024-01-30 16:37:46 +01:00
#=================================================
# RESTORE SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
ynh_restore_file --origin_path="/etc/uwsgi/apps-available/$app.ini"
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
2022-03-13 15:22:35 +01:00
#=================================================
# RESTORE VARIOUS FILES
#=================================================
ynh_script_progression --message="Restoring various files..."
2019-06-06 22:39:49 +02:00
2022-03-14 22:13:23 +01:00
ynh_restore_file --origin_path="/var/lib/pgadmin"
2019-06-06 22:39:49 +02:00
# Restore systemd configuration
ynh_script_progression --message="Reconfiguring application..."
2021-03-07 17:35:19 +01:00
ynh_restore_uwsgi_service
2017-11-14 16:05:26 +01:00
2017-11-16 21:10:21 +01:00
# Set the permission
2019-06-11 22:27:54 +02:00
ynh_script_progression --message="Protecting directory..."
2017-11-16 21:10:21 +01:00
set_permission
2017-11-14 16:05:26 +01:00
2022-03-13 15:22:35 +01:00
#=================================================
# GENERIC FINALIZATION
#=================================================
2024-01-30 17:03:58 +01:00
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
2022-03-13 15:22:35 +01:00
#=================================================
2024-01-30 17:03:58 +01:00
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
2017-11-14 16:05:26 +01:00
2024-01-30 17:03:58 +01:00
ynh_systemd_action --service_name "uwsgi-app@$app.service" --action="restart" --line_match "WSGI app 0 \(mountpoint='[/[:alnum:]_-]*'\) ready in [[:digit:]]* seconds on interpreter" --log_path "/var/log/uwsgi/$app/$app.log"
2020-07-30 22:55:35 +02:00
sleep 10
2019-06-06 22:39:49 +02:00
2024-01-30 17:03:58 +01:00
ynh_systemd_action --service_name=nginx --action=reload
2022-03-13 15:22:35 +01:00
#=================================================
# END OF SCRIPT
#=================================================
2019-06-06 22:39:49 +02:00
ynh_script_progression --message="Restoration completed for $app" --last