Skip to content

Commit

Permalink
get script working with postgres in a container, zsh #8305
Browse files Browse the repository at this point in the history
  • Loading branch information
pdurbin committed Jul 25, 2023
1 parent c3021b8 commit b627319
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions scripts/dev/dev-rebuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ PAYARA_DIR=/usr/local/payara6
ASADMIN=$PAYARA_DIR/glassfish/bin/asadmin
DB_NAME=dvndb
DB_USER=dvnapp
export PGPASSWORD=secret

echo "Checking if there is a war file to undeploy..."
LIST_APP=$($ASADMIN list-applications -t)
Expand All @@ -23,22 +24,22 @@ echo "Deleting ALL DATA FILES uploaded to Dataverse..."
rm -rf $PAYARA_DIR/glassfish/domains/domain1/files

echo "Terminating database sessions so we can drop the database..."
psql -U postgres -c "
psql -h localhost -U postgres -c "
SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
WHERE pg_stat_activity.datname = '$DB_NAME'
AND pid <> pg_backend_pid();
" template1

echo "Dropping the database..."
psql -U $DB_USER -c "DROP DATABASE \"$DB_NAME\"" template1
psql -h localhost -U $DB_USER -c "DROP DATABASE \"$DB_NAME\"" template1
echo $?

echo "Clearing out data from Solr..."
curl http://localhost:8983/solr/collection1/update/json?commit=true -H "Content-type: application/json" -X POST -d "{\"delete\": { \"query\":\"*:*\"}}"
curl "http://localhost:8983/solr/collection1/update/json?commit=true" -H "Content-type: application/json" -X POST -d "{\"delete\": { \"query\":\"*:*\"}}"

echo "Creating a new database..."
psql -U $DB_USER -c "CREATE DATABASE \"$DB_NAME\" WITH OWNER = \"$DB_USER\"" template1
psql -h localhost -U $DB_USER -c "CREATE DATABASE \"$DB_NAME\" WITH OWNER = \"$DB_USER\"" template1
echo $?

echo "Starting app server..."
Expand All @@ -53,7 +54,7 @@ cd scripts/api
cd ../..

echo "Creating SQL sequence..."
psql -U $DB_USER $DB_NAME -f doc/sphinx-guides/source/_static/util/createsequence.sql
psql -h localhost -U $DB_USER $DB_NAME -f doc/sphinx-guides/source/_static/util/createsequence.sql

echo "Setting DOI provider to \"FAKE\"..."
curl http://localhost:8080/api/admin/settings/:DoiProvider -X PUT -d FAKE
Expand Down

0 comments on commit b627319

Please sign in to comment.