aboutsummaryrefslogtreecommitdiff
path: root/debian/db/install/pgsql
diff options
context:
space:
mode:
Diffstat (limited to 'debian/db/install/pgsql')
-rwxr-xr-xdebian/db/install/pgsql99
1 files changed, 28 insertions, 71 deletions
diff --git a/debian/db/install/pgsql b/debian/db/install/pgsql
index 729940d..dab5d1e 100755
--- a/debian/db/install/pgsql
+++ b/debian/db/install/pgsql
@@ -5,77 +5,34 @@ set -eu
5conf_anastasis_db=/etc/anastasis/secrets/anastasis-db.secret.conf 5conf_anastasis_db=/etc/anastasis/secrets/anastasis-db.secret.conf
6conf_override=/etc/anastasis/override.conf 6conf_override=/etc/anastasis/override.conf
7 7
8# get database settings from dbconfig-common and configure 8# Get database settings from dbconfig-common and write anastasis configuration files.
9# for ADMINISTRATIVE access 9if [ -f /etc/dbconfig-common/anastasis-httpd.conf ]; then
10if [ -f /etc/dbconfig-common/anastasis.conf ]; then 10 . /etc/dbconfig-common/anastasis-httpd.conf
11 . /etc/dbconfig-common/anastasis.conf 11 case "$dbc_dbtype" in
12 case "$dbc_dbtype" in 12 pgsql)
13 pgsql) 13 echo -e "# Config file auto-generated by Debian.\n[anastasis]\nDB=postgres\n\n" > \
14 anastasis-config \ 14 $conf_override
15 -c $conf_anastasis_db \ 15 # We assume ident auth here. We might support password auth later.
16 -s "stasis-postgres" \ 16 echo -e "[stasis-postgres]\nCONFIG=postgres:///${dbc_dbname}\n\n" > \
17 -o "CONFIG" \ 17 $conf_anastasis_db
18 -V "postgres:///$dbc_dbname"
19 anastasis-config \
20 -c $conf_override \
21 -s "anastasis" \
22 -o "DB" \
23 -V "postgres"
24 ;;
25 sqlite3)
26 # Later: use something like:
27 # sqlite:///$DATA_DIR/merchant.db
28 # But for now, sqlite is unsupported:
29 echo "Unsupported database type $dbc_type."
30 exit 1
31 ;;
32 "")
33 ;;
34 *)
35 echo "Unsupported database type $dbc_type."
36 exit 1
37 ;;
38 esac
39fi
40
41# Run database initialization logic
42sudo -u postgres anastasis-dbinit -c /etc/anastasis/anastasis.conf
43
44 18
45# get database settings from dbconfig-common and configure 19 # Allow the taler-merchant-httpd user to create schemas, needed by dbinit
46# for service access! 20 echo "GRANT CREATE on database \"$dbc_dbname\" to \"anastasis-httpd\";" | sudo -u postgres psql -f -
47if [ -f /etc/dbconfig-common/anastasis.conf ]; then 21 # Run database initialization logic
48 . /etc/dbconfig-common/anastasis.conf 22 sudo -u anastasis-httpd anastasis-dbinit -c /etc/anastasis/anastasis.conf
49 case "$dbc_dbtype" in 23 ;;
50 pgsql) 24 sqlite3)
51 echo "GRANT INSERT, SELECT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO \"$dbc_dbuser\";" \ 25 # Later: use something like:
52 | sudo -u postgres psql "postgres:///$dbc_dbname" 26 # sqlite:///$DATA_DIR/anastasis.db
53 echo "GRANT SELECT, UPDATE ON ALL SEQUENCES IN SCHEMA public TO \"$dbc_dbuser\";" \ 27 # But for now, sqlite is unsupported:
54 | sudo -u postgres psql "postgres:///$dbc_dbname" 28 echo "Unsupported database type $dbc_type."
29 exit 1
30 ;;
31 "") ;;
55 32
56 anastasis-config \ 33 *)
57 -c $conf_anastasis_db \ 34 echo "Unsupported database type $dbc_type."
58 -s "stasis-postgres" \ 35 exit 1
59 -o "CONFIG" \ 36 ;;
60 -V "postgres://$dbc_dbuser:$dbc_dbpass@$dbc_dbserver/$dbc_dbname" 37 esac
61 anastasis-config \
62 -c $conf_override \
63 -s "anastasis" \
64 -o "DB" \
65 -V "postgres"
66 ;;
67 sqlite3)
68 # Later: use something like:
69 # sqlite:///$DATA_DIR/merchant.db
70 # But for now, sqlite is unsupported:
71 echo "Unsupported database type $dbc_type."
72 exit 1
73 ;;
74 "")
75 ;;
76 *)
77 echo "Unsupported database type $dbc_type."
78 exit 1
79 ;;
80 esac
81fi 38fi