Skip to content

Commit

Permalink
fix: Add PostgreSQL configuration settings
Browse files Browse the repository at this point in the history
This commit fixes an issue where the PostgreSQL configuration settings were not being properly set. The commit adds the necessary lines to the `postgresql.conf` and `pg_hba.conf` files to enable remote connections and set the authentication method to "trust".
  • Loading branch information
SenexCrenshaw committed Feb 5, 2024
1 parent 183cfd3 commit 39f7c1d
Show file tree
Hide file tree
Showing 5 changed files with 464 additions and 27 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,4 @@ dist
ffmpeg/ffmpeg
epg.xml
m3u.m3u
ghtoken
docker-ensure-initdb.sh
docker-entrypoint.sh
ghtoken
2 changes: 1 addition & 1 deletion build_docker.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function Main {
npx semantic-release
}

DownloadFiles
# DownloadFiles

$imageName = "docker.io/senexcrenshaw/streammaster"

Expand Down
73 changes: 73 additions & 0 deletions docker-ensure-initdb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/usr/bin/env bash
set -Eeuo pipefail

#
# This script is intended for three main use cases:
#
# 1. (most importantly) as an example of how to use "docker-entrypoint.sh" to extend/reuse the initialization behavior
#
# 2. ("docker-ensure-initdb.sh") as a Kubernetes "init container" to ensure the provided database directory is initialized; see also "startup probes" for an alternative solution
# (no-op if database is already initialized)
#
# 3. ("docker-enforce-initdb.sh") as part of CI to ensure the database is fully initialized before use
# (error if database is already initialized)
#

source /usr/local/bin/docker-entrypoint.sh

# arguments to this script are assumed to be arguments to the "postgres" server (same as "docker-entrypoint.sh"), and most "docker-entrypoint.sh" functions assume "postgres" is the first argument (see "_main" over there)
if [ "$#" -eq 0 ] || [ "$1" != 'postgres' ]; then
set -- postgres "$@"
fi

# see also "_main" in "docker-entrypoint.sh"

docker_setup_env
# setup data directories and permissions (when run as root)
docker_create_db_directories
if [ "$(id -u)" = '0' ]; then
# then restart script as postgres user
exec gosu postgres "$BASH_SOURCE" "$@"
fi

# only run initialization on an empty data directory
if [ -z "$DATABASE_ALREADY_EXISTS" ]; then
docker_verify_minimum_env

# check dir permissions to reduce likelihood of half-initialized database
ls /docker-entrypoint-initdb.d/ > /dev/null

docker_init_database_dir
pg_setup_hba_conf "$@"

# PGPASSWORD is required for psql when authentication is required for 'local' connections via pg_hba.conf and is otherwise harmless
# e.g. when '--auth=md5' or '--auth-local=md5' is used in POSTGRES_INITDB_ARGS
export PGPASSWORD="${PGPASSWORD:-$POSTGRES_PASSWORD}"
docker_temp_server_start "$@"

docker_setup_db
docker_process_init_files /docker-entrypoint-initdb.d/*

docker_temp_server_stop

unset PGPASSWORD

else
self="$(basename "$0")"
case "$self" in
docker-ensure-initdb.sh)
echo >&2 "$self: note: database already initialized in '$PGDATA'!"
exit 0
;;

docker-enforce-initdb.sh)
echo >&2 "$self: error: (unexpected) database found in '$PGDATA'!"
exit 1
;;

*)
echo >&2 "$self: error: unknown file name: $self"
exit 99
;;
esac
fi
Loading

0 comments on commit 39f7c1d

Please sign in to comment.