commit c9cd57469e7c401c1cd27e6815e68628a42b3931
parent 6c086480e577dc330c5ad27a2dad8c42e1ebe1e3
Author: Antoine A <>
Date: Thu, 28 May 2026 12:40:15 +0200
common: better dbconfig
Diffstat:
1 file changed, 10 insertions(+), 15 deletions(-)
diff --git a/contrib/libeufin-dbconfig b/contrib/libeufin-dbconfig
@@ -1,6 +1,6 @@
#!/bin/bash
# This file is part of GNU TALER.
-# Copyright (C) 2023,2024,2025 Taler Systems SA
+# Copyright (C) 2023,2024,2025,2026 Taler Systems SA
#
# TALER is free software; you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free Software
@@ -231,6 +231,12 @@ function grant_schema_access {
exit_fail "Failed to grant access to schema '$2' to '$1'."
fi
}
+function grant_inheritance {
+ if ! echo "GRANT \"$2\" TO \"$1\"" |
+ sudo -i -u postgres psql "$DBNAME"; then
+ exit_fail "Failed to grant \"$2\" privilege to \"$1\""
+ fi
+}
# Init database with one of the users to create the _v schema
if [ 0 = "$SKIP_INIT" ]; then
@@ -246,24 +252,13 @@ fi
# nexus permission to access db and _v schema if bank init the database
if [[ 0 == "$SKIP_INIT" || 1 == "$FORCE_PERMS" ]] && [[ 0 == "$SKIP_BANK" && 0 == "$SKIP_NEXUS" ]]; then
echo "Setting postgres permissions for '$NEXUS_DBUSER'" 1>&2
- grant_db_access "$NEXUS_DBUSER"
- grant_schema_access "$NEXUS_DBUSER" "_v"
- grant_schema_access "$NEXUS_DBUSER" "libeufin_bank"
+ grant_inheritance "$NEXUS_DBUSER" "$BANK_DBUSER"
fi
# DB initialization for nexus if both component are setup
if [[ 0 == "$SKIP_INIT" && 0 == "$SKIP_BANK" && 0 == "$SKIP_NEXUS" ]]; then
- echo "Initializing database '$DBNAME' for libeufin-nexus." 1>&2
- sudo -u "$NEXUS_DBUSER" "$NEXUS_DBINIT" -c "$NEXUS_CFGFILE"
-fi
-
-# bank permission to access nexus schema if both component are setup
-if [[ 0 == "$SKIP_INIT" || 1 == "$FORCE_PERMS" ]] && [[ 0 == "$SKIP_BANK" && 0 == "$SKIP_NEXUS" ]]; then
- echo "Setting postgres permissions for '$BANK_DBUSER'" 1>&2
- if ! echo "GRANT \"$NEXUS_DBUSER\" TO \"$BANK_DBUSER\"" |
- sudo -i -u postgres psql "$DBNAME"; then
- exit_fail "Failed to grant \"$NEXUS_DBUSER\" privilege to \"$BANK_DBUSER\""
- fi
+ echo "Initializing database '$DBNAME' for libeufin-nexus" 1>&2
+ sudo -u "$BANK_DBUSER" "$NEXUS_DBINIT" -c "$NEXUS_CFGFILE"
fi
echo "Database configuration finished." 1>&2