pretendo-docker/scripts/internal/update-postgres-password.sh
Matthew Lopez 35e64a1044
Create verbose mode for all scripts and reduce default output
Man, dealing with passing arguments through multiple programs correctly is annoying. Tip: don't use eval, use "$@" instead.
2024-05-19 17:26:37 -04:00

23 lines
940 B
Bash
Executable File

#!/usr/bin/env bash
# shellcheck source=./framework.sh
source "$(dirname "$(realpath "$0")")/framework.sh"
parse_arguments "$@"
if [[ ! -f "$git_base_dir/environment/postgres.local.env" ]]; then
print_error "Missing environment file postgres.local.env. Did you run setup-environment.sh?"
exit 1
fi
source "$git_base_dir/environment/postgres.env"
source "$git_base_dir/environment/postgres.local.env"
docker compose up -d postgres
run_command_until_success "Waiting for Postgres to be ready..." 5 \
docker compose exec postgres psql -v ON_ERROR_STOP=1 -U "$POSTGRES_USER" -l
# During the first run, this sometimes fails because the entrypoint script restarts the server after running the initdb
# scripts
run_command_until_success "Failed to change Postgres password, retrying..." 5 \
docker compose exec postgres psql -v ON_ERROR_STOP=1 -U "$POSTGRES_USER" -c "ALTER USER $POSTGRES_USER PASSWORD '$POSTGRES_PASSWORD';"