From cf0539821beb4b65cbb982c76dfc26ec5b16a630 Mon Sep 17 00:00:00 2001 From: Janis Hutz Date: Thu, 30 Jul 2026 10:29:03 +0200 Subject: [PATCH] fix: defaults for postgres fixed --- scripts/postgres-container | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/scripts/postgres-container b/scripts/postgres-container index b213a00..71cc8d7 100755 --- a/scripts/postgres-container +++ b/scripts/postgres-container @@ -8,31 +8,32 @@ read -p "Postgres DB name (default = postgres) " dbname read -p "Postgres DB username (default = postgres) " dbuser read -p "Postgres DB password (default = postgres) " dbpw -if [[ $port == "" ]]; then - port=5432 -fi +port=${port:-5432} +dbname=${dbname:-postgres} +dbuser=${dbuser:-postgres} +dbpw=${dbpw:-postgres} if [[ $2 ]]; then - read -p "Do you wish to mount the data directory to $2/pgdata? (y/N)" domount + read -p "Do you wish to mount the data directory to $2/pgdata? (y/N) " domount - if [[ $domount == "y" ]]; then - mountarg="-v $2/pgdata:/var/lib/postgresql/data" - else - mountarg="" - fi + if [[ $domount == "y" ]]; then + mountarg="-v $2/pgdata:/var/lib/postgresql/data" + else + mountarg="" + fi else - mountarg="" + mountarg="" fi echo " => Starting container with port $port " -docker run --rm \ - $mountarg \ - -p $port:5432 \ - -e POSTGRES_USER=$dbuser \ - -e POSTGRES_PASSWORD=$dbpw \ - -e POSTGRES_DB=$dbname \ - --name $name \ - postgres +docker run \ + $mountarg \ + -p $port:5432 \ + -e POSTGRES_USER=$dbuser \ + -e POSTGRES_PASSWORD=$dbpw \ + -e POSTGRES_DB=$dbname \ + --name $name \ + postgres &