#!/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 source ../settings/scripts/_common.sh source ../settings/scripts/psql.sh # 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) db_user=$(ynh_app_setting_get $app db_user) db_pwd=$(ynh_app_setting_get $app db_pwd) # Install dependance install_dependance # Create user ynh_system_user_create $pgadmin_user /var/lib/pgadmin # Restore all config and data ynh_restore # 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 # Set the permission set_permission # Restrict access to admin only yunohost app addaccess --users=$admin $app # Configuration de logrotate ynh_use_logrotate /var/log/pgadmin # RELOAD NGINX AND PHP-FPM systemctl restart uwsgi systemctl reload nginx