Skip to content

Commit 8de0597

Browse files
authored
Merge pull request #458 from sclorg/add_distgen_generated_files
Add distgen generated files
2 parents 8dc75d7 + 0815688 commit 8de0597

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+3922
-1
lines changed

11/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
root/usr/share/container-scripts/postgresql/README.md

11/cccp.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
job-id: postgresql-11-centos7

11/content_sets.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This is a file defining which content sets are needed to update content in
2+
# this image. Data provided here helps determine which images are vulnerable to
3+
# specific CVEs. Generally you should only need to update this file when:
4+
# 1. You start depending on new product
5+
# 2. You are preparing new product release and your content sets will change
6+
---
7+
x86_64:
8+
- rhel-7-server-rpms
9+
- rhel-7-server-optional-rpms
10+
- rhel-server-rhscl-7-rpms
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
exec "$@"

11/root/usr/bin/run-postgresql

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/bin/bash
2+
3+
export ENABLE_REPLICATION=${ENABLE_REPLICATION:-false}
4+
5+
set -eu
6+
export_vars=$(cgroup-limits) ; export $export_vars
7+
8+
source "${CONTAINER_SCRIPTS_PATH}/common.sh"
9+
10+
set_pgdata
11+
12+
process_extending_files \
13+
"${APP_DATA}/src/postgresql-pre-start" \
14+
"${CONTAINER_SCRIPTS_PATH}/pre-start"
15+
16+
check_env_vars
17+
generate_passwd_file
18+
generate_postgresql_config
19+
20+
# Is this brand new data volume?
21+
PG_INITIALIZED=false
22+
23+
if [ ! -f "$PGDATA/postgresql.conf" ]; then
24+
initialize_database
25+
PG_INITIALIZED=:
26+
else
27+
try_pgupgrade
28+
fi
29+
30+
# Use insanely large timeout (24h) to ensure that the potential recovery has
31+
# enough time here to happen (unless liveness probe kills us). Note that in
32+
# case of server failure this command still exists immediately.
33+
pg_ctl start -w --timeout 86400 -o "-h ''"
34+
35+
# This is just a pedantic safety measure (the timeout above is unlikely to
36+
# happen), but `pt_ctl -w` is not reliable prior to PostgreSQL v10 where it
37+
# returns exit_status=0 even if the server is still starting. For more info
38+
# see the issue#297 and
39+
# https://www.postgresql.org/message-id/CAB7nPqSJs85wK9aknm%3D_jmS6GnH3SQBhpzKcqs8Qo2LhEg2etw%40mail.gmail.com
40+
pg_isready
41+
42+
if $PG_INITIALIZED ; then
43+
process_extending_files \
44+
"${APP_DATA}/src/postgresql-init" \
45+
"${CONTAINER_SCRIPTS_PATH}/init"
46+
migrate_db
47+
create_users
48+
fi
49+
50+
process_extending_files \
51+
"${APP_DATA}/src/postgresql-start" \
52+
"${CONTAINER_SCRIPTS_PATH}/start"
53+
54+
pg_ctl stop
55+
56+
unset_env_vars
57+
echo "Starting server..."
58+
exec postgres "$@"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
export ENABLE_REPLICATION=true
4+
5+
exec run-postgresql "$@"
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash
2+
3+
export ENABLE_REPLICATION=true
4+
5+
set -eu
6+
export_vars=$(cgroup-limits) ; export $export_vars
7+
8+
source "$CONTAINER_SCRIPTS_PATH"/common.sh
9+
10+
set_pgdata
11+
12+
function initialize_replica() {
13+
echo "Initializing PostgreSQL slave ..."
14+
# TODO: Validate and reuse existing data?
15+
rm -rf $PGDATA
16+
PGPASSWORD="${POSTGRESQL_MASTER_PASSWORD}" pg_basebackup -X fetch --no-password --pgdata ${PGDATA} --host=${MASTER_FQDN} --port=5432 -U "${POSTGRESQL_MASTER_USER}"
17+
18+
# PostgreSQL recovery configuration.
19+
generate_postgresql_recovery_config
20+
cat >> "$PGDATA/recovery.conf" <<EOF
21+
22+
# Custom OpenShift recovery configuration:
23+
include '${POSTGRESQL_RECOVERY_FILE}'
24+
EOF
25+
}
26+
27+
check_env_vars
28+
generate_passwd_file
29+
generate_postgresql_config
30+
31+
wait_for_postgresql_master
32+
export MASTER_FQDN=$(postgresql_master_addr)
33+
initialize_replica
34+
35+
unset_env_vars
36+
echo "Starting server..."
37+
exec postgres "$@"

11/root/usr/bin/usage

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
cat /usr/share/container-scripts/postgresql/README.md
4+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#! /bin/sh
2+
3+
# Try whether the PostgreSQL in container accepts connections.
4+
#
5+
# With --live, be tolerant to starting PG server. If the /bin/postgres binary
6+
# has not been executed yet (the shell script is initializing the container),
7+
# wait for it (this script might run forever, we expect that the timeout is
8+
# maintained externally).
9+
10+
test -z "$ENABLED_COLLECTIONS" || . scl_source enable $ENABLED_COLLECTIONS
11+
12+
if test x"$1" = "x--live"; then
13+
# Since livenessProbe is about to detect container deadlocks, and we
14+
# so far don't know about real deadlocks to be detected -- we keep
15+
# liveness probe to report that container is always ready (as long as
16+
# we are able to execute shell, enable collections, etc., which is
17+
# good for container sanity testing anyways).
18+
exit 0
19+
fi
20+
21+
# Readiness check follows, the --timeout is set to "infinite" because it
22+
# is handled externally (readinessProbe.timeoutSeconds).
23+
pg_isready -q \
24+
-h 127.0.0.1 \
25+
${POSTGRESQL_USER+-U "$POSTGRESQL_USER"} \
26+
${POSTGRESQL_DATABASE+-d "$POSTGRESQL_DATABASE"} \
27+
--timeout 0
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/sh
2+
3+
documentation="\
4+
Recursively fix permissions on the given directories to allow GID=0
5+
read/write regular files and read/write/execute directories.
6+
7+
To run this command, you have to be in the group root=0!"
8+
9+
uid=26
10+
write=w
11+
12+
usage ()
13+
{
14+
cat >&2 <<EOF
15+
$0: Error: ${1-usage error}
16+
17+
Usage: $0 [--read-only] DIR [DIR ..]
18+
19+
$documentation
20+
EOF
21+
exit 1
22+
}
23+
24+
while test $# -gt 0; do
25+
case $1 in
26+
--read-only) write= ; shift ;;
27+
*) break ;;
28+
esac
29+
done
30+
31+
test $# -eq 0 && usage "no DIR specified"
32+
33+
for dir; do
34+
test -d "$dir" || usage "no such directory '$dir'"
35+
echo >&2 "fixing permissions on '$dir' directory"
36+
find "$dir" -exec chown "$uid:0" {} \;
37+
find "$dir" -exec chmod "g+r$write" {} \;
38+
find "$dir" -type d -exec chmod g+x {} +
39+
done

0 commit comments

Comments
 (0)