Update 99-run.sh

This commit is contained in:
Alexandre
2024-03-19 12:42:10 +01:00
committed by GitHub
parent 2b632cdd1a
commit f79f8805fd

View File

@@ -15,32 +15,33 @@ 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
fi
else
echo "... using external database"
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
if [ ! -e /config/postgres/postgresql.conf ]; then
sudo -u postgres /usr/lib/postgresql/16/bin/initdb -D /config/postgres
fi
chown -R postgres:postgres /config/postgres
chmod 0700 /config/postgres
echo "... starting server"
sudo -u postgres service postgresql start
sleep 5
echo "... create user and table"
# Set password
sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD 'homeassistant';"
# Create database if does not exist
echo "CREATE ROLE postgres WITH LOGIN SUPERUSER CREATEDB CREATEROLE PASSWORD 'homeassistant';
CREATE DATABASE linkwarden; CREATE USER postgres WITH ENCRYPTED PASSWORD 'homeassistant'; GRANT ALL PRIVILEGES ON DATABASE linkwarden to postgres;
\q"> setup_postgres.sql
sudo -u postgres psql "postgres://postgres:homeassistant@localhost:5432" < setup_postgres.sql || true
fi
########################
@@ -49,4 +50,4 @@ fi
bashio::log.info "Starting app..."
yarn prisma migrate deploy
yarn start docker-entrypoint.sh
docker-entrypoint.sh yarn start