gnunet-svn
[Top][All Lists]
Advanced

[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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]