2024-02-22 11:23:25 +00:00
|
|
|
#!/bin/bash
|
|
|
|
set -e;
|
|
|
|
|
|
|
|
|
|
|
|
if [ -n "${POSTGRES_NON_ROOT_USER:-}" ] && [ -n "${POSTGRES_NON_ROOT_PASSWORD:-}" ]; then
|
2024-09-26 18:05:59 +00:00
|
|
|
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
|
|
|
|
CREATE USER ${POSTGRES_NON_ROOT_USER} WITH PASSWORD '${POSTGRES_NON_ROOT_PASSWORD}';
|
|
|
|
GRANT ALL PRIVILEGES ON DATABASE ${POSTGRES_DB} TO ${POSTGRES_NON_ROOT_USER};
|
|
|
|
GRANT CREATE ON SCHEMA public TO ${POSTGRES_NON_ROOT_USER};
|
|
|
|
EOSQL
|
2024-09-26 17:34:48 +00:00
|
|
|
else
|
2024-09-26 18:05:59 +00:00
|
|
|
echo "SETUP INFO: No Environment variables given!"
|
2024-09-26 17:34:48 +00:00
|
|
|
fi
|