From b74f74013a4da181520fda16086f8bfa7d0eb0e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Wed, 31 Jan 2024 12:23:49 +0100 Subject: [PATCH] Use json file to configure servers to pgadmin --- conf/server.json | 25 +++++++++++++++++++++++++ scripts/install | 9 ++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 conf/server.json diff --git a/conf/server.json b/conf/server.json new file mode 100644 index 0000000..8fae140 --- /dev/null +++ b/conf/server.json @@ -0,0 +1,25 @@ +{ + "Servers": { + "1": { + "Name": "YunoHost Server", + "Group": "Server Group 1", + "Host": "localhost", + "Port": 5432, + "Username": "__DB_USER__", + "Role": "__DB_USER__", + "MaintenanceDB": "postgres", + + "SSLMode": "prefer", + "SSLCert": "/.postgresql/postgresql.crt", + "SSLKey": "/.postgresql/postgresql.key", + + "Timeout": 10, + + "DBRestriction": "live_db test_db", + "PassFile": "/path/to/pgpassfile", + "Shared": false, + "Service": "postgresql-10", + "PasswordExecCommand": "echo '__DB_PWD__'" + } + } +} diff --git a/scripts/install b/scripts/install index ceabbcb..f61c811 100644 --- a/scripts/install +++ b/scripts/install @@ -49,9 +49,12 @@ ynh_script_progression --message="Configuring Postgresql superuser..." ynh_psql_execute_as_root --sql "ALTER USER $app WITH SUPERUSER CREATEDB CREATEROLE REPLICATION" # Add Server In PGadmin database -ynh_add_config --template="setup_database.py" --destination "$install_dir/setup_database.py" -chmod +x "$install_dir/setup_database.py" -"$install_dir/venv/bin/python3" "$install_dir/setup_database.py" "$db_user" "$db_pwd" +# ynh_add_config --template="setup_database.py" --destination "$install_dir/setup_database.py" +# chmod +x "$install_dir/setup_database.py" +# "$install_dir/venv/bin/python3" "$install_dir/setup_database.py" "$db_user" "$db_pwd" + +ynh_add_config --template="server.json" --destination="$install_dir/server.json" +"$install_dir/venv/bin/python3" "$install_dir/venv/lib/python$python_version/site-packages/pgadmin4/setup.py" --load-servers "$install_dir/server.json" # Set permission after initialisation ynh_script_progression --message="Protecting directory"