-
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.
Fixes #13, Update to Environment Variables
- Loading branch information
JolanThomassin
committed
Sep 13, 2023
1 parent
dc31e13
commit 8ba5038
Showing
3 changed files
with
24 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,35 @@ | ||
#!/bin/bash | ||
DIRNAME=$(dirname "$(realpath "$0")") | ||
. "$DIRNAME"/lib.sh | ||
|
||
DIRNAME=$(dirname `realpath $0`) | ||
. $DIRNAME/lib.sh | ||
|
||
PGDATA=$HOME/pgdata | ||
|
||
if [ ! -d $PGDATA ]; then | ||
mkdir -p $PGDATA | ||
if [ -z "${!PGDATA}" ]; then | ||
PGDATA=$HOME/pgdata | ||
fi | ||
|
||
STATUS=`docker inspect louis-db-server -f '{{.State.Status}}'` | ||
if [ ! -d "$PGDATA" ]; then | ||
mkdir -p "$PGDATA" | ||
echo "PGDATA $PGDATA directory does not exist, creating it" | ||
fi | ||
|
||
check_environment_variables_defined DB_SERVER_CONTAINER_NAME PGPASSWORD | ||
|
||
STATUS=$(docker inspect "$DB_SERVER_CONTAINER_NAME" -f '{{.State.Status}}') | ||
|
||
if [ "$STATUS" = "exited" ]; then | ||
echo "container $DB_SERVER_CONTAINER_NAME exist but has exited, restarting" | ||
docker start louis-db-server | ||
docker start "$DB_SERVER_CONTAINER_NAME" | ||
|
||
elif [ "$STATUS" != "running" ]; then | ||
echo container does not exist, creating | ||
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