* fix #426

* fix logic to get versions
pull/435/head
mazano 2023-07-01 09:47:21 +02:00 zatwierdzone przez GitHub
rodzic fd0f76c291
commit 863494e5af
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 26 dodań i 2 usunięć

Wyświetl plik

@ -272,6 +272,13 @@ POSTGRES_MULTIPLE_EXTENSIONS=postgis,pgrouting:3.4.0
where `pgrouting:3.4.0` The extension name is fixed with the version name with the delimiter being a
colon.
**Note** In some cases, some versions of extensions might not be available for
install. To enable them you can do the following inside the container:
```bash
wget --directory-prefix /usr/share/postgresql/15/extension/ https://raw.githubusercontent.com/postgres/postgres/master/contrib/hstore/hstore--1.1--1.2.sql
```
Then proceed to install it the normal way.
#### Shared preload libraries
Some PostgreSQL extensions require shared_preload_libraries to be specified in the conf files.

Wyświetl plik

@ -17,6 +17,7 @@ RECOVERY_CONF="$ROOT_CONF/recovery.conf"
POSTGRES="/usr/lib/postgresql/${POSTGRES_MAJOR_VERSION}/bin/postgres"
INITDB="/usr/lib/postgresql/${POSTGRES_MAJOR_VERSION}/bin/initdb"
SQLDIR="/usr/share/postgresql/${POSTGRES_MAJOR_VERSION}/contrib/postgis-${POSTGIS_MAJOR}.${POSTGIS_MINOR_RELEASE}/"
EXTDIR="/usr/share/postgresql/${POSTGRES_MAJOR_VERSION}/extension/"
SETVARS="POSTGIS_ENABLE_OUTDB_RASTERS=1 POSTGIS_GDAL_ENABLED_DRIVERS=ENABLE_ALL"
LOCALONLY="-c listen_addresses='127.0.0.1'"
PG_BASEBACKUP="/usr/bin/pg_basebackup"
@ -526,9 +527,25 @@ function extension_install() {
psql ${DATABASE} -U ${POSTGRES_USER} -p 5432 -h localhost -c "CREATE EXTENSION IF NOT EXISTS \"${EXTENSION_NAME}\" cascade;"
fi
else
echo -e "\e[32m [Entrypoint] Installing extension \e[1;31m ${EXTENSION_NAME} \e[32m with version \e[1;31m ${EXTENSION_VERSION} \e[32m in the database : \e[1;31m ${DATABASE} \033[0m"
if [[ ${EXTENSION_NAME} != 'pg_cron' ]]; then
psql ${DATABASE} -U ${POSTGRES_USER} -p 5432 -h localhost -c "CREATE EXTENSION IF NOT EXISTS \"${EXTENSION_NAME}\" WITH VERSION '${EXTENSION_VERSION}' cascade;"
pattern="${EXTENSION_NAME}--"
last_numbers=()
for file in "$EXTDIR"/${pattern}*; do
filename=$(basename "$file" .sql)
if [[ "$filename" == *"--"* ]]; then
last_number=$(echo "$filename" | awk -F '--' '{print $NF}')
if [[ ! " ${last_numbers[@]} " =~ " $last_number " ]]; then
last_numbers+=("$last_number")
fi
fi
done
if [[ " ${last_numbers[@]} " =~ " $EXTENSION_VERSION " ]]; then
echo -e "\e[32m [Entrypoint] Installing extension \e[1;31m ${EXTENSION_NAME} \e[32m with version \e[1;31m ${EXTENSION_VERSION} \e[32m in the database : \e[1;31m ${DATABASE} \033[0m"
psql ${DATABASE} -U ${POSTGRES_USER} -p 5432 -h localhost -c "CREATE EXTENSION IF NOT EXISTS \"${EXTENSION_NAME}\" WITH VERSION '${EXTENSION_VERSION}' cascade;"
else
echo -e "\e[32m [Entrypoint] Extension \e[1;31m ${EXTENSION_NAME} \e[32m with version \e[1;31m ${EXTENSION_VERSION} \e[32m is not available for install, available versions to install are \e[1;31m "${last_numbers[@]}" \033[0m"
fi
fi
fi