mirror of
https://github.com/YunoHost-Apps/pgadmin_ynh.git
synced 2024-09-03 19:56:38 +02:00
82 lines
3.2 KiB
Bash
82 lines
3.2 KiB
Bash
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
|
source ../settings/scripts/experimental_helper.sh
|
|
source ../settings/scripts/_common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# RESTORE THE APP MAIN DIR
|
|
#=================================================
|
|
ynh_script_progression --message="Restoring the app main directory..." --weight=1
|
|
|
|
ynh_restore_file --origin_path="$install_dir"
|
|
|
|
### $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"
|
|
|
|
#=================================================
|
|
# RESTORE THE POSTGRESQL SUPERUSER
|
|
#=================================================
|
|
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"
|
|
|
|
#=================================================
|
|
# REINSTALL DEPENDENCIES
|
|
#=================================================
|
|
ynh_script_progression --message="Updating python virtualenv..." --weight=5
|
|
|
|
ynh_install_venv
|
|
|
|
#=================================================
|
|
# 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"
|
|
|
|
#=================================================
|
|
# RESTORE VARIOUS FILES
|
|
#=================================================
|
|
ynh_script_progression --message="Restoring various files..."
|
|
|
|
ynh_restore_file --origin_path="/var/lib/pgadmin"
|
|
|
|
# Restore systemd configuration
|
|
ynh_script_progression --message="Reconfiguring application..."
|
|
ynh_restore_uwsgi_service
|
|
|
|
# Set the permission
|
|
ynh_script_progression --message="Protecting directory..."
|
|
set_permission
|
|
|
|
#=================================================
|
|
# GENERIC FINALIZATION
|
|
#=================================================
|
|
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
|
|
#=================================================
|
|
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
|
|
|
|
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"
|
|
sleep 10
|
|
|
|
ynh_systemd_action --service_name=nginx --action=reload
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Restoration completed for $app" --last
|