#!/bin/sh -e

tar -xzvf $HOME/dellstore2-normal-1.0.tar.gz

PG_USER=omnidb
PG_PASS=omnidb
PG_DATABASE=omnidb_tests
PG_DUMP=$HOME/dellstore2-normal-1.0/dellstore2-normal-1.0.sql

PG_PORT=5494

psql -p $PG_PORT -c "CREATE USER $PG_USER WITH PASSWORD '$PG_PASS' SUPERUSER"
psql -p $PG_PORT -c "CREATE DATABASE $PG_DATABASE WITH OWNER=$PG_USER"
PGPASSWORD=$PG_PASS psql -h localhost -p $PG_PORT -d $PG_DATABASE -U $PG_USER -f $PG_DUMP

PG_PORT=5495

psql -p $PG_PORT -c "CREATE USER $PG_USER WITH PASSWORD '$PG_PASS' SUPERUSER"
psql -p $PG_PORT -c "CREATE DATABASE $PG_DATABASE WITH OWNER=$PG_USER"
PGPASSWORD=$PG_PASS psql -h localhost -p $PG_PORT -d $PG_DATABASE -U $PG_USER -f $PG_DUMP

PG_PORT=5496

psql -p $PG_PORT -c "CREATE USER $PG_USER WITH PASSWORD '$PG_PASS' SUPERUSER"
psql -p $PG_PORT -c "CREATE DATABASE $PG_DATABASE WITH OWNER=$PG_USER"
PGPASSWORD=$PG_PASS psql -h localhost -p $PG_PORT -d $PG_DATABASE -U $PG_USER -f $PG_DUMP

PG_PORT=5410

psql -p $PG_PORT -c "CREATE USER $PG_USER WITH PASSWORD '$PG_PASS' SUPERUSER"
psql -p $PG_PORT -c "CREATE DATABASE $PG_DATABASE WITH OWNER=$PG_USER"
PGPASSWORD=$PG_PASS psql -h localhost -p $PG_PORT -d $PG_DATABASE -U $PG_USER -f $PG_DUMP

PG_PORT=5411

psql -p $PG_PORT -c "CREATE USER $PG_USER WITH PASSWORD '$PG_PASS' SUPERUSER"
psql -p $PG_PORT -c "CREATE DATABASE $PG_DATABASE WITH OWNER=$PG_USER"
PGPASSWORD=$PG_PASS psql -h localhost -p $PG_PORT -d $PG_DATABASE -U $PG_USER -f $PG_DUMP

PG_PORT=5412

psql -p $PG_PORT -c "CREATE USER $PG_USER WITH PASSWORD '$PG_PASS' SUPERUSER"
psql -p $PG_PORT -c "CREATE DATABASE $PG_DATABASE WITH OWNER=$PG_USER"
PGPASSWORD=$PG_PASS psql -h localhost -p $PG_PORT -d $PG_DATABASE -U $PG_USER -f $PG_DUMP

rm -rf $HOME/dellstore2-normal-1.0/
