Skip to content
Snippets Groups Projects
Commit 76029b71 authored by Mike Beattie's avatar Mike Beattie
Browse files

Add support for specifying Postgres port


Signed-off-by: default avatarMike Beattie <mike@ethernal.org>
parent 06b728ae
No related branches found
No related tags found
No related merge requests found
......@@ -12,6 +12,7 @@ An initial user is created during database initialisation by the application, sp
|`ADMIN_USER`|`admin`|Initial admin username for DNS UI|
|`MAIL_SERVER`|`smtp`|SMTP mail server hostname for outgoing mail|
|`POSTGRES_HOST`|`postgres`|Postgresql database host|
|`POSTGRES_PORT`|`5432`|Postgresql database port|
|`POSTGRES_DB`|`dnsui`|Database name|
|`POSTGRES_USER`|`dnsui`|Database user/role|
|`POSTGRES_PASSWORD`|`dnsui`|Database password|
......
......@@ -28,7 +28,7 @@ report_name = "Domain administrator"
[database]
; Connection details to the Postgres database
dsn = "pgsql:host=__POSTGRES_HOST__;dbname=__POSTGRES_DB__"
dsn = "pgsql:host=__POSTGRES_HOST__;port=__POSTGRES_PORT__;dbname=__POSTGRES_DB__"
username = "__POSTGRES_USER__"
password = "__POSTGRES_PASSWORD__"
......
......@@ -9,6 +9,7 @@ services:
environment:
- ADMIN_USER=admin
- POSTGRES_HOST=dnsui-db
- POSTGRES_PORT=5432
- POSTGRES_DB=dnsui
- POSTGRES_USER=dnsui
- POSTGRES_PASSWORD=dnsui
......
......@@ -5,6 +5,7 @@ set -e
ADMIN_USER=${ADMIN_USER:-admin}
MAIL_SERVER=${MAIL_SERVER:-smtp}
POSTGRES_HOST=${POSTGRES_HOST:-postgres}
POSTGRES_PORT=${POSTGRES_PORT:-5432}
POSTGRES_DB=${POSTGRES_DB:-pdns}
POSTGRES_USER=${POSTGRES_USER:-pdns}
POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-pdns}
......@@ -24,7 +25,7 @@ ln -sf /data/config.ini /srv/dns-ui/config/
if grep -q '^; AUTOCONFIG_ENABLED=yes$' /data/config.ini; then
echo "Updating configuration..."
sed -e "s/^\(dsn\s*=\s*\"pgsql:host=\)[^;]\+\(;dbname=\)[^;]\+\"$/\1${POSTGRES_HOST}\2${POSTGRES_DB}\"/" \
sed -e "s/^\(dsn\s*=\s*\"pgsql:host=\)[^;]\+\(;port=\)[^;]\+\(;dbname=\)[^;]\+\"$/\1${POSTGRES_HOST}\2${POSTGRES_PORT}\3${POSTGRES_DB}\"/" \
-e "s/^\(username\s*=\s*\"\).*\"$/\1${POSTGRES_USER}\"/" \
-e "s/^\(password\s*=\s*\"\).*\"$/\1${POSTGRES_PASSWORD}\"/" \
-e "s/^\(api_url\s*=\s*\"http:\/\/\).*\(\/api\/v1\/servers\/localhost\"\)$/\1${PDNS_API_HOST}:${PDNS_API_PORT}\2/" \
......@@ -46,7 +47,7 @@ if ! grep -q 'INSERT INTO "user"' /srv/dns-ui/migrations/002.php; then
EOF
fi
while ! nc -z "$POSTGRES_HOST" 5432; do
while ! nc -z "$POSTGRES_HOST" "$POSTGRES_PORT"; do
echo "Waiting for database..."
sleep 1
done
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment