mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-06-03 14:24:06 +02:00
Update 99-run.sh
This commit is contained in:
@@ -15,32 +15,33 @@ 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
|
||||||
|
if [ ! -e /config/postgres/postgresql.conf ]; then
|
||||||
echo "... starting server"
|
sudo -u postgres /usr/lib/postgresql/16/bin/initdb -D /config/postgres
|
||||||
service postgresql start & true
|
fi
|
||||||
sleep 5
|
chown -R postgres:postgres /config/postgres
|
||||||
|
chmod 0700 /config/postgres
|
||||||
echo "... create user"
|
|
||||||
# Create database if does not exist
|
echo "... starting server"
|
||||||
echo "CREATE ROLE postgres WITH LOGIN SUPERUSER CREATEDB CREATEROLE PASSWORD 'homeassistant';
|
sudo -u postgres service postgresql start
|
||||||
\q"> setup_postgres.sql
|
sleep 5
|
||||||
psql "postgres://postgres:homeassistant&localhost:5432/linkwarden" < setup_postgres.sql || true
|
|
||||||
|
echo "... create user and table"
|
||||||
if [ -e /config/postgres/postgresql.conf ]; then
|
# Set password
|
||||||
echo "... database already configured"
|
sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD 'homeassistant';"
|
||||||
else
|
|
||||||
echo "configure database"
|
# Create database if does not exist
|
||||||
postgres /usr/lib/postgresql/*/bin/initdb
|
echo "CREATE ROLE postgres WITH LOGIN SUPERUSER CREATEDB CREATEROLE PASSWORD 'homeassistant';
|
||||||
fi
|
CREATE DATABASE linkwarden; CREATE USER postgres WITH ENCRYPTED PASSWORD 'homeassistant'; GRANT ALL PRIVILEGES ON DATABASE linkwarden to postgres;
|
||||||
else
|
\q"> setup_postgres.sql
|
||||||
echo "... using external database"
|
sudo -u postgres psql "postgres://postgres:homeassistant@localhost:5432" < setup_postgres.sql || true
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
########################
|
########################
|
||||||
@@ -49,4 +50,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
|
docker-entrypoint.sh yarn start
|
||||||
|
|||||||
Reference in New Issue
Block a user