From 6e97bf67d65bd515656d7763a9a55f9a62ee892c Mon Sep 17 00:00:00 2001 From: Aleksey Filippov Date: Tue, 28 May 2019 22:27:35 +0400 Subject: [PATCH] try-vue: add pgsql runner --- deploy/run_psql.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 deploy/run_psql.sh diff --git a/deploy/run_psql.sh b/deploy/run_psql.sh new file mode 100644 index 0000000..5532e93 --- /dev/null +++ b/deploy/run_psql.sh @@ -0,0 +1,24 @@ +#!/bin/bash +# to run this execute +# export PSQL_HOME_DIR=/home/user/pgsql-10.5.1; bash ./deploy/run_psql.sh +PSQL_DATA_DIR=./ng-tracker +PSQL_USER_NAME=postgres +PSQL_DB_NAME=ng-tracker +if [ ! -d "$PSQL_HOME_DIR" ]; then + echo "Directory $PSQL_HOME_DIR is not exists" + exit 0 +fi +cd "$PSQL_HOME_DIR" +if [ ! -d "$PSQL_DATA_DIR" ]; then + ./bin/initdb "$PSQL_DATA_DIR" + ./bin/pg_ctl -D "$PSQL_DATA_DIR" start + ./bin/createuser -s "$PSQL_USER_NAME" + ./bin/createdb -O "$PSQL_USER_NAME" "$PSQL_DB_NAME" +else + PSQL_STATUS=$(./bin/pg_ctl -D "$PSQL_DATA_DIR" status | wc -l) + if [ $PSQL_STATUS -eq 1 ]; then + ./bin/pg_ctl -D "$PSQL_DATA_DIR" start + else + ./bin/pg_ctl -D "$PSQL_DATA_DIR" stop + fi +fi