From 603edcbdc17f2b9b6ee187933a162cb1ee5047df Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Wed, 22 Jan 2025 08:28:21 +0100 Subject: [PATCH] Create 10-vector.sh --- .../docker-entrypoint-initdb.d/10-vector.sh | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 postgres/rootfs/docker-entrypoint-initdb.d/10-vector.sh diff --git a/postgres/rootfs/docker-entrypoint-initdb.d/10-vector.sh b/postgres/rootfs/docker-entrypoint-initdb.d/10-vector.sh new file mode 100644 index 000000000..5948b479e --- /dev/null +++ b/postgres/rootfs/docker-entrypoint-initdb.d/10-vector.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bashio +# shellcheck shell=bash +set -e + +bashio::log.info "Waiting for port 5432 to open..." + +# Wait for transmission to become available +( bashio::net.wait_for 5432 localhost 900 + +bashio::log.info "Enabling vector.rs" + +# Set variables for vector.rs +DB_PORT=5432 +DB_HOSTNAME=localhost +DB_PASSWORD="$(bashio::config 'POSTGRES_PASSWORD')" +if bashio::config.has_value "POSTGRES_USER"; then DB_USERNAME="$(bashio::config "POSTGRES_USER")"; else DB_USERNAME=postgres; fi + +export DB_PORT +export DB_HOSTNAME +export DB_USERNAME +export DB_PASSWORD +echo "DROP EXTENSION IF EXISTS vectors; + CREATE EXTENSION vectors; +\q" > /setup_postgres.sql + +# Enable vectors +psql "postgres://$DB_USERNAME:$DB_PASSWORD@$DB_HOSTNAME:$DB_PORT" < /setup_postgres.sql >/dev/null || true +rm /setup_postgres.sql || true +) & true