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

47 lines
1.1 KiB
Text
Raw Normal View History

2017-11-14 16:05:26 +01:00
#!/bin/bash
# IMPORT GENERIC HELPERS
source /usr/share/yunohost/helpers
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
# Import common cmd
2017-11-16 21:10:21 +01:00
source ../settings/scripts/_common.sh
source ../settings/scripts/psql.sh
2017-11-14 16:05:26 +01:00
# LOAD SETTINGS
domain=$(ynh_app_setting_get $app domain)
path_url=$(ynh_app_setting_get $app path)
admin=$(ynh_app_setting_get $app admin)
final_path=$(ynh_app_setting_get $app final_path)
db_name=$(ynh_app_setting_get $app db_name)
2017-11-16 21:10:21 +01:00
db_user=$(ynh_app_setting_get $app db_user)
db_pwd=$(ynh_app_setting_get $app db_pwd)
2017-11-14 16:05:26 +01:00
2017-11-16 21:10:21 +01:00
# Install dependance
install_dependance
2017-11-14 16:05:26 +01:00
2017-11-16 21:10:21 +01:00
# Create user
ynh_system_user_create $pgadmin_user /var/lib/pgadmin
2017-11-14 16:05:26 +01:00
2017-11-16 21:10:21 +01:00
# Restore all config and data
ynh_restore
2017-11-14 16:05:26 +01:00
2017-11-16 21:10:21 +01:00
# POPULATE THE DATABASE
ynh_psql_test_if_first_run
su --command="psql -c\"CREATE USER ${db_user} WITH PASSWORD '${db_pwd}' SUPERUSER CREATEDB CREATEROLE REPLICATION\"" postgres
2017-11-14 16:05:26 +01:00
2017-11-16 21:10:21 +01:00
# Set the permission
set_permission
2017-11-14 16:05:26 +01:00
2017-11-16 21:10:21 +01:00
# Restrict access to admin only
yunohost app addaccess --users=$admin $app
2017-11-14 16:05:26 +01:00
2017-11-16 21:10:21 +01:00
# Configuration de logrotate
ynh_use_logrotate /var/log/pgadmin
2017-11-14 16:05:26 +01:00
# RELOAD NGINX AND PHP-FPM
2017-11-16 21:10:21 +01:00
systemctl restart uwsgi
2017-11-14 16:05:26 +01:00
systemctl reload nginx