-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from ai-cfia/JolanThomassin/issue13
Fixes #13, Update Server Configuration
- Loading branch information
Showing
4 changed files
with
57 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,35 @@ | ||
#!/bin/bash | ||
DIRNAME=$(dirname "$(realpath "$0")") | ||
. "$DIRNAME"/lib.sh | ||
|
||
DIRNAME=$(dirname `realpath $0`) | ||
. $DIRNAME/lib.sh | ||
|
||
PGDATA=$HOME/pgdata | ||
if [ -z "${!PGDATA}" ]; then | ||
PGDATA=$HOME/pgdata | ||
fi | ||
|
||
if [ ! -d $PGDATA ]; then | ||
mkdir -p $PGDATA | ||
if [ ! -d "$PGDATA" ]; then | ||
mkdir -p "$PGDATA" | ||
echo "PGDATA $PGDATA directory does not exist, creating it" | ||
fi | ||
|
||
STATUS=`docker inspect louis-db-server -f '{{.State.Status}}'` | ||
check_environment_variables_defined DB_SERVER_CONTAINER_NAME PGPASSWORD | ||
|
||
STATUS=$(docker inspect "$DB_SERVER_CONTAINER_NAME" -f '{{.State.Status}}') | ||
|
||
if [ "$STATUS" = "exited" ]; then | ||
docker start louis-db-server | ||
echo "container $DB_SERVER_CONTAINER_NAME exist but has exited, restarting" | ||
docker start "$DB_SERVER_CONTAINER_NAME" | ||
|
||
elif [ "$STATUS" != "running" ]; then | ||
docker run --name louis-db-server \ | ||
-e POSTGRES_PASSWORD=$PGPASSWORD \ | ||
|
||
echo "container $DB_SERVER_CONTAINER_NAME does not exist, creating" | ||
|
||
docker run --name "$DB_SERVER_CONTAINER_NAME" \ | ||
-e POSTGRES_PASSWORD="$PGPASSWORD" \ | ||
--network louis_network \ | ||
--mount type=bind,src=$PGDATA,target=/var/lib/postgresql/data \ | ||
--mount type=bind,src="$PGDATA",target=/var/lib/postgresql/data \ | ||
--publish 5432:5432 \ | ||
--user "$(id -u):$(id -g)" -v /etc/passwd:/etc/passwd:ro \ | ||
-d louis-postgres | ||
-d "louis-postgres" | ||
else | ||
echo "Postgres is already running" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters