summaryrefslogtreecommitdiff
path: root/debian/db
diff options
context:
space:
mode:
Diffstat (limited to 'debian/db')
-rwxr-xr-x[-rw-r--r--]debian/db/install/pgsql73
-rw-r--r--debian/db/upgrade/pgsql2
2 files changed, 72 insertions, 3 deletions
diff --git a/debian/db/install/pgsql b/debian/db/install/pgsql
index f15429b0..8173aeff 100644..100755
--- a/debian/db/install/pgsql
+++ b/debian/db/install/pgsql
@@ -1,2 +1,73 @@
#!/bin/sh
-taler-merchant-dbinit -c /etc/taler-merchant.conf
+
+set -eu
+
+# get database settings from dbconfig-common and configure
+# for ADMINISTRATIVE access
+if [ -f /etc/dbconfig-common/taler-merchant.conf ]; then
+ . /etc/dbconfig-common/taler-merchant.conf
+ case "$dbc_dbtype" in
+ pgsql)
+ taler-config -w \
+ -c /etc/taler-merchant.conf \
+ -s "merchantdb-postgres" \
+ -o "CONFIG" \
+ -V "postgres:///$dbc_dbname"
+ taler-config -w \
+ -c /etc/taler-merchant.conf \
+ -s "merchant" \
+ -o "DB" \
+ -V "postgres"
+ ;;
+ sqlite3)
+ # Later: use something like:
+ # sqlite:///$DATA_DIR/merchant.db
+ # But for now, sqlite is unsupported:
+ echo "Unsupported database type $dbc_type."
+ exit 1
+ ;;
+ "")
+ ;;
+ *)
+ echo "Unsupported database type $dbc_type."
+ exit 1
+ ;;
+ esac
+fi
+
+# Run database initialization logic
+sudo -u postgres taler-merchant-dbinit -c /etc/taler-merchant.conf
+
+
+# get database settings from dbconfig-common and configure
+# for service access!
+if [ -f /etc/dbconfig-common/taler-merchant.conf ]; then
+ . /etc/dbconfig-common/taler-merchant.conf
+ case "$dbc_dbtype" in
+ pgsql)
+ taler-config -w \
+ -c /etc/taler-merchant.conf \
+ -s "merchantdb-postgres" \
+ -o "CONFIG" \
+ -V "postgres://$dbc_dbuser:$dbc_dbpass@$dbc_dbserver/$dbc_dbname"
+ taler-config -w \
+ -c /etc/taler-merchant.conf \
+ -s "merchant" \
+ -o "DB" \
+ -V "postgres"
+ ;;
+ sqlite3)
+ # Later: use something like:
+ # sqlite:///$DATA_DIR/merchant.db
+ # But for now, sqlite is unsupported:
+ echo "Unsupported database type $dbc_type."
+ exit 1
+ ;;
+ "")
+ ;;
+ *)
+ echo "Unsupported database type $dbc_type."
+ exit 1
+ ;;
+ esac
+fi
diff --git a/debian/db/upgrade/pgsql b/debian/db/upgrade/pgsql
deleted file mode 100644
index f15429b0..00000000
--- a/debian/db/upgrade/pgsql
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/sh
-taler-merchant-dbinit -c /etc/taler-merchant.conf