Skip to content

Commit

Permalink
Start implementing db creation if not exists
Browse files Browse the repository at this point in the history
  • Loading branch information
lildude committed May 23, 2024
1 parent 8ec1cba commit 5cbde22
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ RUN \
curl \
jq \
nginx \
postgresql-client \
tzdata \
xz-utils \
&& rm -rf /var/lib/apt/lists/* \
Expand Down
6 changes: 6 additions & 0 deletions services/teslamate/run
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ if bashio::config.true 'grafana_import_dashboards'; then
/dashboards.sh restore
fi

# Create the PostgreSQL database if it doesn't exist
if ! pg_isready -h "$DATABASE_HOST" -p "$DATABASE_PORT" -U "$DATABASE_USER" -d "$DATABASE_NAME"; then
bashio::log.info "Creating database $DATABASE_NAME on $DATABASE_HOST"
psql -h "$DATABASE_HOST" -p "$DATABASE_PORT" -U "$DATABASE_USER" -c "CREATE DATABASE $DATABASE_NAME"
fi

# https://developers.home-assistant.io/blog/2023/04/13/new_limits_for_add_ons/
ulimit -n 1048576

Expand Down

0 comments on commit 5cbde22

Please sign in to comment.