summaryrefslogtreecommitdiff
path: root/debian/db/install/pgsql
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-07-30 10:38:27 +0200
committerChristian Grothoff <christian@grothoff.org>2021-07-30 10:38:27 +0200
commit7e669bcf6b6336ec429da949bcb4aa456971dba2 (patch)
treed19912f950d1cac1c38b857b7d5bdaba2289544e /debian/db/install/pgsql
downloadanastasis-7e669bcf6b6336ec429da949bcb4aa456971dba2.tar.gz
anastasis-7e669bcf6b6336ec429da949bcb4aa456971dba2.tar.bz2
anastasis-7e669bcf6b6336ec429da949bcb4aa456971dba2.zip
folding history in preparation of GNU Anastasis v0.0.0 release
Diffstat (limited to 'debian/db/install/pgsql')
-rwxr-xr-xdebian/db/install/pgsql78
1 files changed, 78 insertions, 0 deletions
diff --git a/debian/db/install/pgsql b/debian/db/install/pgsql
new file mode 100755
index 0000000..d61008c
--- /dev/null
+++ b/debian/db/install/pgsql
@@ -0,0 +1,78 @@
+#!/bin/sh
+
+set -eu
+
+# get database settings from dbconfig-common and configure
+# for ADMINISTRATIVE access
+if [ -f /etc/dbconfig-common/anastasis.conf ]; then
+ . /etc/dbconfig-common/anastasis.conf
+ case "$dbc_dbtype" in
+ pgsql)
+ anastasis-config -w \
+ -c /etc/anastasis.conf \
+ -s "stasis-postgres" \
+ -o "CONFIG" \
+ -V "postgres:///$dbc_dbname"
+ anastasis-config -w \
+ -c /etc/anastasis.conf \
+ -s "anastasis" \
+ -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 anastasis-dbinit -c /etc/anastasis.conf
+
+
+# get database settings from dbconfig-common and configure
+# for service access!
+if [ -f /etc/dbconfig-common/anastasis.conf ]; then
+ . /etc/dbconfig-common/anastasis.conf
+ case "$dbc_dbtype" in
+ pgsql)
+ echo "GRANT INSERT, SELECT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO \"$dbc_dbuser\";" \
+ | sudo -u postgres psql "postgres:///$dbc_dbname"
+ echo "GRANT SELECT, UPDATE ON ALL SEQUENCES IN SCHEMA public TO \"$dbc_dbuser\";" \
+ | sudo -u postgres psql "postgres:///$dbc_dbname"
+
+ anastasis-config -w \
+ -c /etc/anastasis.conf \
+ -s "stasis-postgres" \
+ -o "CONFIG" \
+ -V "postgres://$dbc_dbuser:$dbc_dbpass@$dbc_dbserver/$dbc_dbname"
+ anastasis-config -w \
+ -c /etc/anastasis.conf \
+ -s "anastasis" \
+ -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