From d7723c75fd1344d3427f2990bc2305393f138af5 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Tue, 19 Mar 2024 08:26:48 +0100 Subject: [PATCH] Update 99-run.sh --- linkwarden/rootfs/etc/cont-init.d/99-run.sh | 49 +++++++++++---------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/linkwarden/rootfs/etc/cont-init.d/99-run.sh b/linkwarden/rootfs/etc/cont-init.d/99-run.sh index f4e8a0020..e365a6ec0 100755 --- a/linkwarden/rootfs/etc/cont-init.d/99-run.sh +++ b/linkwarden/rootfs/etc/cont-init.d/99-run.sh @@ -15,29 +15,30 @@ mkdir -p /config/library bashio::log.info "Setting postgres..." if [[ "$DATABASE_URL" == *"localhost"* ]]; then -echo "... with local database" -echo "... set database in /config/postgres" -mkdir -p /config/postgres -mkdir -p /var/run/postgresql -chown postgres:postgres /var/run/postgresql -chown -R postgres:postgres /config/postgres -chmod 0700 /config/postgres - -echo "... starting server" -service postgresql start & true -sleep 5 - -echo "... create user" -# Create database if does not exist -echo "CREATE ROLE postgres WITH LOGIN SUPERUSER CREATEDB CREATEROLE PASSWORD 'homeassistant'; -\q"> setup_postgres.sql -psql "postgres://postgres:homeassistant&localhost:5432/linkwarden" < setup_postgres.sql || true - -if [ -e /config/postgres/postgresql.conf ]; then - echo "... database already configured" -else - echo "configure database" - postgres /usr/lib/postgresql/*/bin/initdb + echo "... with local database" + echo "... set database in /config/postgres" + mkdir -p /config/postgres + mkdir -p /var/run/postgresql + chown postgres:postgres /var/run/postgresql + chown -R postgres:postgres /config/postgres + chmod 0700 /config/postgres + + echo "... starting server" + service postgresql start & true + sleep 5 + + echo "... create user" + # Create database if does not exist + echo "CREATE ROLE postgres WITH LOGIN SUPERUSER CREATEDB CREATEROLE PASSWORD 'homeassistant'; + \q"> setup_postgres.sql + psql "postgres://postgres:homeassistant&localhost:5432/linkwarden" < setup_postgres.sql || true + + if [ -e /config/postgres/postgresql.conf ]; then + echo "... database already configured" + else + echo "configure database" + postgres /usr/lib/postgresql/*/bin/initdb + fi fi ######################## @@ -46,4 +47,4 @@ fi bashio::log.info "Starting app..." yarn prisma migrate deploy -yarn start docker-entrypoint.sh & true +yarn start docker-entrypoint.sh