docker-postgis/scripts/docker-entrypoint.sh

66 wiersze
1.7 KiB
Bash
Czysty Zwykły widok Historia

#!/usr/bin/env bash
set -e
source /scripts/env-data.sh
# Setup postgres CONF file
source /scripts/setup-conf.sh
# Setup ssl
source /scripts/setup-ssl.sh
# Setup pg_hba.conf
source /scripts/setup-pg_hba.sh
2021-06-06 15:36:15 +00:00
# Function to add figlet
figlet -t "Kartoza Docker PostGIS"
if [[ -f /scripts/.pass_20.txt ]]; then
USER_CREDENTIAL_PASS=$(cat /scripts/.pass_20.txt)
cp /scripts/.pass_20.txt /tmp/PGPASSWORD.txt
echo -e "[Entrypoint] GENERATED Postgres PASSWORD: \e[1;31m $USER_CREDENTIAL_PASS"
echo -e "\033[0m PGPASSWORD Generated above: "
fi
if [[ -f /scripts/.pass_22.txt ]]; then
USER_CREDENTIAL_PASS=$(cat /scripts/.pass_22.txt)
cp /scripts/.pass_22.txt /tmp/REPLPASSWORD.txt
echo -e "[Entrypoint] GENERATED Replication PASSWORD: \e[1;34m $USER_CREDENTIAL_PASS"
echo -e "\033[0m Replication password Generated above: "
fi
if [[ -z "$REPLICATE_FROM" ]]; then
# This means this is a master instance. We check that database exists
echo "Setup master database"
source /scripts/setup-database.sh
entry_point_script
kill_postgres
else
# This means this is a slave/replication instance.
echo "Setup slave database"
source /scripts/setup-replication.sh
fi
# If no arguments passed to entrypoint, then run postgres by default
if [[ $# -eq 0 ]];
then
echo "Postgres initialisation process completed .... restarting in foreground"
su - postgres -c "$SETVARS $POSTGRES -D $DATADIR -c config_file=$CONF"
fi
# If arguments passed, run postgres with these arguments
# This will make sure entrypoint will always be executed
if [[ "${1:0:1}" = '-' ]]; then
# append postgres into the arguments
set -- postgres "$@"
fi
2021-06-06 15:36:15 +00:00
exec su - "$@"