summaryrefslogtreecommitdiff
path: root/debian/db/install/pgsql
diff options
context:
space:
mode:
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