diff --git a/9.2/docker-entrypoint.sh b/9.2/docker-entrypoint.sh index 66ea0f1d94..d89f0d5f1f 100755 --- a/9.2/docker-entrypoint.sh +++ b/9.2/docker-entrypoint.sh @@ -23,6 +23,25 @@ file_env() { unset "$fileVar" } +# Execute scripts from a given folder +# usage: exec_scripts FOLDER +exec_scripts() { + local execDir="$1" + local fileList=(${execDir}/*) + if [ ${#fileList[@]} -gt 0 ]; then + echo + for f in "${fileList[@]}"; do + case "$f" in + *.sh) echo "$0: running $f"; . "$f" ;; + *.sql) echo "$0: running $f"; "${psql[@]}" -f "$f"; echo ;; + *.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${psql[@]}"; echo ;; + *) echo "$0: ignoring $f" ;; + esac + echo + done + fi +} + if [ "${1:0:1}" = '-' ]; then set -- postgres "$@" fi @@ -37,6 +56,7 @@ if [ "$1" = 'postgres' ] && [ "$(id -u)" = '0' ]; then chown -R postgres /var/run/postgresql chmod g+s /var/run/postgresql + exec_scripts "/docker-entrypoint-preexec.d" exec gosu postgres "$BASH_SOURCE" "$@" fi @@ -110,15 +130,7 @@ if [ "$1" = 'postgres' ]; then psql+=( --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" ) echo - for f in /docker-entrypoint-initdb.d/*; do - case "$f" in - *.sh) echo "$0: running $f"; . "$f" ;; - *.sql) echo "$0: running $f"; "${psql[@]}" -f "$f"; echo ;; - *.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${psql[@]}"; echo ;; - *) echo "$0: ignoring $f" ;; - esac - echo - done + exec_scripts "/docker-entrypoint-initdb.d" PGUSER="${PGUSER:-postgres}" \ pg_ctl -D "$PGDATA" -m fast -w stop @@ -129,4 +141,5 @@ if [ "$1" = 'postgres' ]; then fi fi +exec_scripts "/docker-entrypoint-preexec.d" exec "$@" diff --git a/9.3/docker-entrypoint.sh b/9.3/docker-entrypoint.sh index 66ea0f1d94..d89f0d5f1f 100755 --- a/9.3/docker-entrypoint.sh +++ b/9.3/docker-entrypoint.sh @@ -23,6 +23,25 @@ file_env() { unset "$fileVar" } +# Execute scripts from a given folder +# usage: exec_scripts FOLDER +exec_scripts() { + local execDir="$1" + local fileList=(${execDir}/*) + if [ ${#fileList[@]} -gt 0 ]; then + echo + for f in "${fileList[@]}"; do + case "$f" in + *.sh) echo "$0: running $f"; . "$f" ;; + *.sql) echo "$0: running $f"; "${psql[@]}" -f "$f"; echo ;; + *.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${psql[@]}"; echo ;; + *) echo "$0: ignoring $f" ;; + esac + echo + done + fi +} + if [ "${1:0:1}" = '-' ]; then set -- postgres "$@" fi @@ -37,6 +56,7 @@ if [ "$1" = 'postgres' ] && [ "$(id -u)" = '0' ]; then chown -R postgres /var/run/postgresql chmod g+s /var/run/postgresql + exec_scripts "/docker-entrypoint-preexec.d" exec gosu postgres "$BASH_SOURCE" "$@" fi @@ -110,15 +130,7 @@ if [ "$1" = 'postgres' ]; then psql+=( --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" ) echo - for f in /docker-entrypoint-initdb.d/*; do - case "$f" in - *.sh) echo "$0: running $f"; . "$f" ;; - *.sql) echo "$0: running $f"; "${psql[@]}" -f "$f"; echo ;; - *.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${psql[@]}"; echo ;; - *) echo "$0: ignoring $f" ;; - esac - echo - done + exec_scripts "/docker-entrypoint-initdb.d" PGUSER="${PGUSER:-postgres}" \ pg_ctl -D "$PGDATA" -m fast -w stop @@ -129,4 +141,5 @@ if [ "$1" = 'postgres' ]; then fi fi +exec_scripts "/docker-entrypoint-preexec.d" exec "$@" diff --git a/9.4/docker-entrypoint.sh b/9.4/docker-entrypoint.sh index 66ea0f1d94..d89f0d5f1f 100755 --- a/9.4/docker-entrypoint.sh +++ b/9.4/docker-entrypoint.sh @@ -23,6 +23,25 @@ file_env() { unset "$fileVar" } +# Execute scripts from a given folder +# usage: exec_scripts FOLDER +exec_scripts() { + local execDir="$1" + local fileList=(${execDir}/*) + if [ ${#fileList[@]} -gt 0 ]; then + echo + for f in "${fileList[@]}"; do + case "$f" in + *.sh) echo "$0: running $f"; . "$f" ;; + *.sql) echo "$0: running $f"; "${psql[@]}" -f "$f"; echo ;; + *.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${psql[@]}"; echo ;; + *) echo "$0: ignoring $f" ;; + esac + echo + done + fi +} + if [ "${1:0:1}" = '-' ]; then set -- postgres "$@" fi @@ -37,6 +56,7 @@ if [ "$1" = 'postgres' ] && [ "$(id -u)" = '0' ]; then chown -R postgres /var/run/postgresql chmod g+s /var/run/postgresql + exec_scripts "/docker-entrypoint-preexec.d" exec gosu postgres "$BASH_SOURCE" "$@" fi @@ -110,15 +130,7 @@ if [ "$1" = 'postgres' ]; then psql+=( --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" ) echo - for f in /docker-entrypoint-initdb.d/*; do - case "$f" in - *.sh) echo "$0: running $f"; . "$f" ;; - *.sql) echo "$0: running $f"; "${psql[@]}" -f "$f"; echo ;; - *.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${psql[@]}"; echo ;; - *) echo "$0: ignoring $f" ;; - esac - echo - done + exec_scripts "/docker-entrypoint-initdb.d" PGUSER="${PGUSER:-postgres}" \ pg_ctl -D "$PGDATA" -m fast -w stop @@ -129,4 +141,5 @@ if [ "$1" = 'postgres' ]; then fi fi +exec_scripts "/docker-entrypoint-preexec.d" exec "$@" diff --git a/9.5/docker-entrypoint.sh b/9.5/docker-entrypoint.sh index 66ea0f1d94..d89f0d5f1f 100755 --- a/9.5/docker-entrypoint.sh +++ b/9.5/docker-entrypoint.sh @@ -23,6 +23,25 @@ file_env() { unset "$fileVar" } +# Execute scripts from a given folder +# usage: exec_scripts FOLDER +exec_scripts() { + local execDir="$1" + local fileList=(${execDir}/*) + if [ ${#fileList[@]} -gt 0 ]; then + echo + for f in "${fileList[@]}"; do + case "$f" in + *.sh) echo "$0: running $f"; . "$f" ;; + *.sql) echo "$0: running $f"; "${psql[@]}" -f "$f"; echo ;; + *.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${psql[@]}"; echo ;; + *) echo "$0: ignoring $f" ;; + esac + echo + done + fi +} + if [ "${1:0:1}" = '-' ]; then set -- postgres "$@" fi @@ -37,6 +56,7 @@ if [ "$1" = 'postgres' ] && [ "$(id -u)" = '0' ]; then chown -R postgres /var/run/postgresql chmod g+s /var/run/postgresql + exec_scripts "/docker-entrypoint-preexec.d" exec gosu postgres "$BASH_SOURCE" "$@" fi @@ -110,15 +130,7 @@ if [ "$1" = 'postgres' ]; then psql+=( --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" ) echo - for f in /docker-entrypoint-initdb.d/*; do - case "$f" in - *.sh) echo "$0: running $f"; . "$f" ;; - *.sql) echo "$0: running $f"; "${psql[@]}" -f "$f"; echo ;; - *.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${psql[@]}"; echo ;; - *) echo "$0: ignoring $f" ;; - esac - echo - done + exec_scripts "/docker-entrypoint-initdb.d" PGUSER="${PGUSER:-postgres}" \ pg_ctl -D "$PGDATA" -m fast -w stop @@ -129,4 +141,5 @@ if [ "$1" = 'postgres' ]; then fi fi +exec_scripts "/docker-entrypoint-preexec.d" exec "$@" diff --git a/9.6/docker-entrypoint.sh b/9.6/docker-entrypoint.sh index 66ea0f1d94..d89f0d5f1f 100755 --- a/9.6/docker-entrypoint.sh +++ b/9.6/docker-entrypoint.sh @@ -23,6 +23,25 @@ file_env() { unset "$fileVar" } +# Execute scripts from a given folder +# usage: exec_scripts FOLDER +exec_scripts() { + local execDir="$1" + local fileList=(${execDir}/*) + if [ ${#fileList[@]} -gt 0 ]; then + echo + for f in "${fileList[@]}"; do + case "$f" in + *.sh) echo "$0: running $f"; . "$f" ;; + *.sql) echo "$0: running $f"; "${psql[@]}" -f "$f"; echo ;; + *.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${psql[@]}"; echo ;; + *) echo "$0: ignoring $f" ;; + esac + echo + done + fi +} + if [ "${1:0:1}" = '-' ]; then set -- postgres "$@" fi @@ -37,6 +56,7 @@ if [ "$1" = 'postgres' ] && [ "$(id -u)" = '0' ]; then chown -R postgres /var/run/postgresql chmod g+s /var/run/postgresql + exec_scripts "/docker-entrypoint-preexec.d" exec gosu postgres "$BASH_SOURCE" "$@" fi @@ -110,15 +130,7 @@ if [ "$1" = 'postgres' ]; then psql+=( --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" ) echo - for f in /docker-entrypoint-initdb.d/*; do - case "$f" in - *.sh) echo "$0: running $f"; . "$f" ;; - *.sql) echo "$0: running $f"; "${psql[@]}" -f "$f"; echo ;; - *.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${psql[@]}"; echo ;; - *) echo "$0: ignoring $f" ;; - esac - echo - done + exec_scripts "/docker-entrypoint-initdb.d" PGUSER="${PGUSER:-postgres}" \ pg_ctl -D "$PGDATA" -m fast -w stop @@ -129,4 +141,5 @@ if [ "$1" = 'postgres' ]; then fi fi +exec_scripts "/docker-entrypoint-preexec.d" exec "$@" diff --git a/LICENSE b/LICENSE index 4f324b2254..3b550ffdbc 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2014-2015, Docker PostgreSQL Authors (See AUTHORS) +Copyright (c) 2014-2017, Docker PostgreSQL Authors (See AUTHORS) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 66ea0f1d94..d89f0d5f1f 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -23,6 +23,25 @@ file_env() { unset "$fileVar" } +# Execute scripts from a given folder +# usage: exec_scripts FOLDER +exec_scripts() { + local execDir="$1" + local fileList=(${execDir}/*) + if [ ${#fileList[@]} -gt 0 ]; then + echo + for f in "${fileList[@]}"; do + case "$f" in + *.sh) echo "$0: running $f"; . "$f" ;; + *.sql) echo "$0: running $f"; "${psql[@]}" -f "$f"; echo ;; + *.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${psql[@]}"; echo ;; + *) echo "$0: ignoring $f" ;; + esac + echo + done + fi +} + if [ "${1:0:1}" = '-' ]; then set -- postgres "$@" fi @@ -37,6 +56,7 @@ if [ "$1" = 'postgres' ] && [ "$(id -u)" = '0' ]; then chown -R postgres /var/run/postgresql chmod g+s /var/run/postgresql + exec_scripts "/docker-entrypoint-preexec.d" exec gosu postgres "$BASH_SOURCE" "$@" fi @@ -110,15 +130,7 @@ if [ "$1" = 'postgres' ]; then psql+=( --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" ) echo - for f in /docker-entrypoint-initdb.d/*; do - case "$f" in - *.sh) echo "$0: running $f"; . "$f" ;; - *.sql) echo "$0: running $f"; "${psql[@]}" -f "$f"; echo ;; - *.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${psql[@]}"; echo ;; - *) echo "$0: ignoring $f" ;; - esac - echo - done + exec_scripts "/docker-entrypoint-initdb.d" PGUSER="${PGUSER:-postgres}" \ pg_ctl -D "$PGDATA" -m fast -w stop @@ -129,4 +141,5 @@ if [ "$1" = 'postgres' ]; then fi fi +exec_scripts "/docker-entrypoint-preexec.d" exec "$@"