depolymerization

wire gateway for Bitcoin/Ethereum
Log | Files | Refs | Submodules | README | LICENSE

tmp_db.sh (702B)


      1 #!/bin/bash
      2 
      3 ## Generate a new database in a temporary directory for instrumentation test against a local blockchain
      4 
      5 source "${BASH_SOURCE%/*}/common.sh"
      6 
      7 DIR=$(mktemp -d)
      8 
      9 # Cleanup to run whenever we exit
     10 function cleanup() {
     11     pg_ctl stop -D $DIR -w &> /dev/null
     12     wait
     13     rm -rf $DIR &> /dev/null || true
     14 }
     15 
     16 # Install cleanup handler (except for kill -9)
     17 trap cleanup EXIT
     18 
     19 echo  "----- Setup db -----"
     20 pg_ctl init -D $DIR
     21 echo "port=5454" >> $DIR/postgresql.conf
     22 pg_ctl start -D $DIR -o "-c unix_socket_directories=$DIR"
     23 echo "CREATE ROLE postgres LOGIN SUPERUSER PASSWORD 'password'" | psql -h localhost -p 5454 postgres > /dev/null
     24 echo ""
     25 
     26 read -p "Waiting for input to close DB:" IGNORE