Update 99-run.sh

This commit is contained in:
Alexandre
2024-03-19 08:26:48 +01:00
committed by GitHub
parent 32ada7f09d
commit d7723c75fd

View File

@@ -15,29 +15,30 @@ mkdir -p /config/library
bashio::log.info "Setting postgres..." bashio::log.info "Setting postgres..."
if [[ "$DATABASE_URL" == *"localhost"* ]]; then if [[ "$DATABASE_URL" == *"localhost"* ]]; then
echo "... with local database" echo "... with local database"
echo "... set database in /config/postgres" echo "... set database in /config/postgres"
mkdir -p /config/postgres mkdir -p /config/postgres
mkdir -p /var/run/postgresql mkdir -p /var/run/postgresql
chown postgres:postgres /var/run/postgresql chown postgres:postgres /var/run/postgresql
chown -R postgres:postgres /config/postgres chown -R postgres:postgres /config/postgres
chmod 0700 /config/postgres chmod 0700 /config/postgres
echo "... starting server" echo "... starting server"
service postgresql start & true service postgresql start & true
sleep 5 sleep 5
echo "... create user" echo "... create user"
# Create database if does not exist # Create database if does not exist
echo "CREATE ROLE postgres WITH LOGIN SUPERUSER CREATEDB CREATEROLE PASSWORD 'homeassistant'; echo "CREATE ROLE postgres WITH LOGIN SUPERUSER CREATEDB CREATEROLE PASSWORD 'homeassistant';
\q"> setup_postgres.sql \q"> setup_postgres.sql
psql "postgres://postgres:homeassistant&localhost:5432/linkwarden" < setup_postgres.sql || true psql "postgres://postgres:homeassistant&localhost:5432/linkwarden" < setup_postgres.sql || true
if [ -e /config/postgres/postgresql.conf ]; then if [ -e /config/postgres/postgresql.conf ]; then
echo "... database already configured" echo "... database already configured"
else else
echo "configure database" echo "configure database"
postgres /usr/lib/postgresql/*/bin/initdb postgres /usr/lib/postgresql/*/bin/initdb
fi
fi fi
######################## ########################
@@ -46,4 +47,4 @@ fi
bashio::log.info "Starting app..." bashio::log.info "Starting app..."
yarn prisma migrate deploy yarn prisma migrate deploy
yarn start docker-entrypoint.sh & true yarn start docker-entrypoint.sh