[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-grid5k] 61/73: refactor db.sh
From: |
gnunet |
Subject: |
[taler-grid5k] 61/73: refactor db.sh |
Date: |
Tue, 14 Dec 2021 15:10:43 +0100 |
This is an automated email from the git hooks/post-receive script.
marco-boss pushed a commit to branch master
in repository grid5k.
commit 31178d952a0ebba3f7ead8cdcb195d5dff1278e5
Author: Boss Marco <bossm8@bfh.ch>
AuthorDate: Fri Dec 10 18:46:39 2021 +0100
refactor db.sh
---
experiment/scripts/database.sh | 51 ++++++++++++++++++++++++------------------
1 file changed, 29 insertions(+), 22 deletions(-)
diff --git a/experiment/scripts/database.sh b/experiment/scripts/database.sh
index 3f0631e..923498d 100755
--- a/experiment/scripts/database.sh
+++ b/experiment/scripts/database.sh
@@ -107,21 +107,19 @@ function setup_config() {
/etc/pgbouncer/pgbouncer.ini
}
-if [[ "$1" == "init" ]]; then
- setup_config
-# setup_disks
-fi
-
-systemctl restart postgresql
+function setup_pgbouncer() {
+ if [ "${USE_PGBOUNCER}" = "true" ]; then
+ # pgbouncer does not cleanup those sometimes
+ rm -f /var/run/postgresql/pgbouncer.pid
+ rm -f /var/run/postgresql/.s.PGSQL.6432
+ systemctl restart pgbouncer
+ fi
+}
-if [ "${USE_PGBOUNCER}" = "true" ]; then
- # pgbouncer does not cleanup those sometimes
- rm -f /var/run/postgresql/pgbouncer.pid
- rm -f /var/run/postgresql/.s.PGSQL.6432
- systemctl restart pgbouncer
-fi
+function init_db() {
+ systemctl restart postgresql
-su postgres << EOF
+ su postgres << EOF
psql postgres -tAc "SELECT 1 FROM pg_roles WHERE
rolname='taler-exchange-httpd'" | \
grep -q 1 || \
createuser taler-exchange-httpd
@@ -129,12 +127,12 @@ psql -tAc "SELECT 1 FROM pg_database WHERE
datname='${DB_NAME}'" | \
grep -q 1 || \
createdb -O taler-exchange-httpd "${DB_NAME}"
EOF
-
-sudo -u taler-exchange-httpd taler-exchange-dbinit -r || true
-sudo -u taler-exchange-httpd taler-exchange-dbinit -s || true
-sudo -u taler-exchange-httpd taler-exchange-dbinit
-
-su postgres << EOF
+
+ sudo -u taler-exchange-httpd taler-exchange-dbinit -r || true
+ sudo -u taler-exchange-httpd taler-exchange-dbinit -s || true
+ sudo -u taler-exchange-httpd taler-exchange-dbinit
+
+ su postgres << EOF
psql postgres -tAc "SELECT 1 FROM pg_roles WHERE rolname='${DB_USER}'" | \
grep -q 1 \
|| psql << END
@@ -142,13 +140,22 @@ psql postgres -tAc "SELECT 1 FROM pg_roles WHERE
rolname='${DB_USER}'" | \
CREATE EXTENSION pg_stat_statements;
END
EOF
-
-su taler-exchange-httpd -s /bin/bash << EOF
+
+ su taler-exchange-httpd -s /bin/bash << EOF
psql -d "${DB_NAME}"
GRANT SELECT,INSERT,UPDATE ON ALL TABLES IN SCHEMA public TO "${DB_USER}";
GRANT USAGE ON ALL SEQUENCES IN SCHEMA public TO "${DB_USER}";
EOF
+}
-restart_rsyslog
+case ${1} in
+ init)
+ setup_config
+ #setup_disks
+ init_db
+ setup_pgbouncer
+ restart_rsyslog
+ ;;
+esac
exit 0
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-grid5k] 10/73: update service files, (continued)
- [taler-grid5k] 10/73: update service files, gnunet, 2021/12/14
- [taler-grid5k] 34/73: exporter for merchant now on monitor too, gnunet, 2021/12/14
- [taler-grid5k] 24/73: cleanup with functions - try work_mem and idle_in_transaction, gnunet, 2021/12/14
- [taler-grid5k] 15/73: build wallet from source since dist does not work, gnunet, 2021/12/14
- [taler-grid5k] 25/73: enable postgres-exporter again, gnunet, 2021/12/14
- [taler-grid5k] 29/73: switch to transaction mode since otherwise its all the same as when pgbouncer not used at all, gnunet, 2021/12/14
- [taler-grid5k] 23/73: disable pgbouncer per default, gnunet, 2021/12/14
- [taler-grid5k] 52/73: possible to configure max_requests with env file, gnunet, 2021/12/14
- [taler-grid5k] 22/73: add pgbouncer, tune pg config, gnunet, 2021/12/14
- [taler-grid5k] 16/73: fix wallet build - broken on master, gnunet, 2021/12/14
- [taler-grid5k] 61/73: refactor db.sh,
gnunet <=
- [taler-grid5k] 30/73: increase default pool size, gnunet, 2021/12/14
- [taler-grid5k] 43/73: update config of db and exch, gnunet, 2021/12/14
- [taler-grid5k] 44/73: -resolve conflict, gnunet, 2021/12/14
- [taler-grid5k] 41/73: update installer script, gnunet, 2021/12/14
- [taler-grid5k] 54/73: enable huge_pages, implement exchange scrape logic, gnunet, 2021/12/14
- [taler-grid5k] 48/73: update install script, gnunet, 2021/12/14
- [taler-grid5k] 37/73: bootstrap seems to work with sudo, gnunet, 2021/12/14
- [taler-grid5k] 47/73: fix stupid bug and fix arguments for bank, gnunet, 2021/12/14
- [taler-grid5k] 55/73: db disk mount, gnunet, 2021/12/14
- [taler-grid5k] 42/73: fix setup.sh, gnunet, 2021/12/14