aboutsummaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
authorAntoine A <>2022-02-23 18:43:29 +0100
committerAntoine A <>2022-02-23 18:43:29 +0100
commite18367bae0a1cd3223896a6e55e7fac4b14f5266 (patch)
tree7978e1d8eff6dacfe88743d26efb1c383a7ce0f9 /script
parentd2a167cd660f3beae6dc4515b85a71bff9383f5d (diff)
downloaddepolymerization-e18367bae0a1cd3223896a6e55e7fac4b14f5266.tar.gz
depolymerization-e18367bae0a1cd3223896a6e55e7fac4b14f5266.tar.bz2
depolymerization-e18367bae0a1cd3223896a6e55e7fac4b14f5266.zip
Better initialization and improved instrumentation test
Diffstat (limited to 'script')
-rw-r--r--script/tmp_db.sh26
1 files changed, 26 insertions, 0 deletions
diff --git a/script/tmp_db.sh b/script/tmp_db.sh
new file mode 100644
index 0000000..aa19eb8
--- /dev/null
+++ b/script/tmp_db.sh
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+## Generate a new database in a temporary directory for instrumentation test against a local blockchain
+
+source "${BASH_SOURCE%/*}/common.sh"
+
+DIR=$(mktemp -d)
+
+# Cleanup to run whenever we exit
+function cleanup() {
+ pg_ctl stop -D $DIR -w &> /dev/null
+ wait
+ rm -rf $DIR &> /dev/null || true
+}
+
+# Install cleanup handler (except for kill -9)
+trap cleanup EXIT
+
+echo "----- Setup db -----"
+pg_ctl init -D $DIR
+echo "port=5454" >> $DIR/postgresql.conf
+pg_ctl start -D $DIR -o "-c unix_socket_directories=$DIR"
+echo "CREATE ROLE postgres LOGIN SUPERUSER PASSWORD 'password'" | psql -h localhost -p 5454 postgres > /dev/null
+echo ""
+
+read -p "Waiting for input to close DB:" IGNORE