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

84 lines
2.9 KiB
Text
Raw Normal View History

2017-11-14 16:05:26 +01:00
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
2020-11-17 23:51:51 +01:00
# Import common cmd
source ../settings/scripts/experimental_helper.sh
source ../settings/scripts/_common.sh
2017-11-14 16:05:26 +01:00
# IMPORT GENERIC HELPERS
source /usr/share/yunohost/helpers
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
# LOAD SETTINGS
2019-06-06 22:39:49 +02:00
ynh_script_progression --message="Loading settings..."
domain=$(ynh_app_setting_get --app $app --key domain)
path_url=$(ynh_app_setting_get --app $app --key path)
admin=$(ynh_app_setting_get --app $app --key admin)
final_path=$(ynh_app_setting_get --app $app --key final_path)
db_name=$(ynh_app_setting_get --app $app --key db_name)
db_user=$(ynh_app_setting_get --app $app --key db_user)
db_pwd=$(ynh_app_setting_get --app $app --key db_pwd)
2020-11-28 19:24:23 +01:00
app_version=$(ynh_app_upstream_version)
app_main_version=$(echo $app_version | cut -d'-' -f1)
app_sub_version=$(echo $app_version | cut -d'-' -f2)
2017-11-14 16:05:26 +01:00
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
2017-11-16 21:10:21 +01:00
# Install dependance
2019-06-06 22:39:49 +02:00
ynh_script_progression --message="Reinstalling dependencies..." --weight=5
ynh_install_app_dependencies $dependances
2017-11-14 16:05:26 +01:00
2017-11-16 21:10:21 +01:00
# Create user
2019-06-06 22:39:49 +02:00
ynh_script_progression --message="Recreating the dedicated system user..."
ynh_system_user_create --username $pgadmin_user --home_dir $final_path
2017-11-14 16:05:26 +01:00
2017-11-16 21:10:21 +01:00
# Restore all config and data
2019-06-06 22:39:49 +02:00
ynh_script_progression --message="Restoring files..." --weight=5
2017-11-16 21:10:21 +01:00
ynh_restore
2017-11-14 16:05:26 +01:00
# Check that the good python version is installed
# If not upgrade the source
2020-07-31 22:56:34 +02:00
install_source
2017-11-16 21:10:21 +01:00
# POPULATE THE DATABASE
2019-06-06 22:39:49 +02:00
ynh_script_progression --message="Reconfiguring Postgresql database..."
2017-11-16 21:10:21 +01:00
ynh_psql_test_if_first_run
2019-06-06 22:39:49 +02:00
ynh_psql_execute_as_root \
--sql "CREATE USER ${db_user} WITH PASSWORD '${db_pwd}' SUPERUSER CREATEDB CREATEROLE REPLICATION"
# 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
#=================================================
# GENERIC FINALIZATION
#=================================================
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
2017-11-16 21:10:21 +01:00
# Restrict access to admin only
ynh_script_progression --message="Configuring permissions"
ynh_permission_update --permission="main" --remove="all_users" --add=$admin
2017-11-14 16:05:26 +01:00
2017-11-16 21:10:21 +01:00
# Configuration de logrotate
2019-06-06 22:39:49 +02:00
ynh_script_progression --message="Configuring log rotation..."
2019-10-01 21:31:45 +02:00
ynh_use_logrotate --logfile /var/log/pgadmin
2017-11-14 16:05:26 +01:00
2018-03-15 23:33:57 +01:00
# reload uwsgi and nginx
2019-06-11 22:27:54 +02:00
ynh_script_progression --message="Starting pgadmin services..." --weight=3
2019-06-06 22:39:49 +02:00
ynh_systemd_action --service_name "uwsgi-app@$app.service" \
--line_match "WSGI app 0 \(mountpoint='[/[:alnum:]_-]*'\) ready in [[:digit:]]* seconds on interpreter" --log_path "/var/log/uwsgi/$app/$app.log"
2017-11-14 16:05:26 +01:00
systemctl reload nginx
2020-07-30 22:55:35 +02:00
sleep 10
2019-06-06 22:39:49 +02:00
ynh_script_progression --message="Restoration completed for $app" --last