initial commit
This commit is contained in:
commit
f6b4c20e4a
14 changed files with 160 additions and 0 deletions
19
rootfs/bin/renew-certificates
Executable file
19
rootfs/bin/renew-certificates
Executable file
|
@ -0,0 +1,19 @@
|
|||
#!/usr/bin/with-contenv sh
|
||||
|
||||
cd /var/lib/postgresql
|
||||
|
||||
OLD_MOD=$(stat -c %y /var/lib/postgresql/.lego/certificates/${POSTGRES_DOMAIN}.crt)
|
||||
|
||||
lego \
|
||||
--accept-tos \
|
||||
--server="${POSTGRES_CA}" \
|
||||
--email="${POSTGRES_ACME_EMAIL}" \
|
||||
--domains="${POSTGRES_DOMAIN}" \
|
||||
--dns="${POSTGRES_DNS_PROVIDER}" \
|
||||
renew --days 30
|
||||
|
||||
NEW_MOD=$(stat -c %y /var/lib/postgresql/.lego/certificates/${POSTGRES_DOMAIN}.crt)
|
||||
|
||||
if [ "${OLD_MOD}" != "${NEW_MOD}" ]; then
|
||||
kill -s TERM $(head -1 ${PGDATA}/postmaster.pid)
|
||||
fi
|
5
rootfs/etc/confd/conf.d/pg_hba.conf.toml
Normal file
5
rootfs/etc/confd/conf.d/pg_hba.conf.toml
Normal file
|
@ -0,0 +1,5 @@
|
|||
[template]
|
||||
src = "pg_hba.conf.tmpl"
|
||||
dest = "/var/lib/postgresql/data/pg_hba.conf"
|
||||
gid = 70
|
||||
uid = 70
|
3
rootfs/etc/confd/templates/pg_hba.conf.tmpl
Normal file
3
rootfs/etc/confd/templates/pg_hba.conf.tmpl
Normal file
|
@ -0,0 +1,3 @@
|
|||
local all all trust
|
||||
hostssl all all 0.0.0.0/0 md5
|
||||
host all all ::1/128 trust
|
5
rootfs/etc/cont-init.d/00-initdb
Normal file
5
rootfs/etc/cont-init.d/00-initdb
Normal file
|
@ -0,0 +1,5 @@
|
|||
#!/usr/bin/with-contenv sh
|
||||
|
||||
if [ ! -f ${PGDATA}/PG_VERSION ]; then
|
||||
s6-setuidgid postgres initdb --username=postgres
|
||||
fi
|
11
rootfs/etc/cont-init.d/00-password
Normal file
11
rootfs/etc/cont-init.d/00-password
Normal file
|
@ -0,0 +1,11 @@
|
|||
#!/usr/bin/with-contenv sh
|
||||
|
||||
cat <<EOF > /var/lib/postgresql/data/pg_hba.conf
|
||||
local all all trust
|
||||
EOF
|
||||
|
||||
s6-setuidgid postgres pg_ctl -D "$PGDATA" -o "-c listen_addresses='localhost'" -w start
|
||||
|
||||
s6-setuidgid postgres psql --command "ALTER USER postgres WITH PASSWORD '${POSTGRES_PASSWORD}';"
|
||||
|
||||
s6-setuidgid postgres pg_ctl -D "$PGDATA" -o "-c listen_addresses='localhost'" -w stop
|
30
rootfs/etc/cont-init.d/02-certificates
Normal file
30
rootfs/etc/cont-init.d/02-certificates
Normal file
|
@ -0,0 +1,30 @@
|
|||
#!/usr/bin/with-contenv sh
|
||||
|
||||
cd /var/lib/postgresql
|
||||
|
||||
SAN_DOMAINS=""
|
||||
|
||||
export IFS=";"
|
||||
for SAN in ${POSTGRES_SAN}
|
||||
do
|
||||
SAN_DOMAINS="${SAN_DOMAINS} --domains=\"${SAN}\""
|
||||
done
|
||||
|
||||
if [ ! -f /var/lib/postgresql/.lego/certificates/${POSTGRES_DOMAIN}.crt ]; then
|
||||
chown -R postgres /var/lib/postgresql/.lego
|
||||
s6-setuidgid postgres lego \
|
||||
--accept-tos \
|
||||
--server="${POSTGRES_CA}" \
|
||||
--email="${POSTGRES_ACME_EMAIL}" \
|
||||
--domains="${POSTGRES_DOMAIN}" ${SAN_DOMAINS} \
|
||||
--dns="${POSTGRES_DNS_PROVIDER}" \
|
||||
run
|
||||
else
|
||||
s6-setuidgid postgres lego \
|
||||
--accept-tos \
|
||||
--server="${POSTGRES_CA}" \
|
||||
--email="${POSTGRES_ACME_EMAIL}" \
|
||||
--domains="${POSTGRES_DOMAIN}" \
|
||||
--dns="${POSTGRES_DNS_PROVIDER}" \
|
||||
renew --days 30
|
||||
fi
|
1
rootfs/etc/fix-attrs.d/01-pgdata
Normal file
1
rootfs/etc/fix-attrs.d/01-pgdata
Normal file
|
@ -0,0 +1 @@
|
|||
/var/lib/postgresql true postgres 0600 0700
|
8
rootfs/etc/services.d/postgres/run
Executable file
8
rootfs/etc/services.d/postgres/run
Executable file
|
@ -0,0 +1,8 @@
|
|||
#!/usr/bin/with-contenv sh
|
||||
|
||||
s6-setuidgid postgres postgres \
|
||||
-D $PGDATA \
|
||||
-c listen_addresses='*' \
|
||||
-c ssl=on \
|
||||
-c ssl_cert_file="/var/lib/postgresql/.lego/certificates/${POSTGRES_DOMAIN}.crt" \
|
||||
-c ssl_key_file="/var/lib/postgresql/.lego/certificates/${POSTGRES_DOMAIN}.key"
|
1
rootfs/var/spool/cron/crontab/postgres
Normal file
1
rootfs/var/spool/cron/crontab/postgres
Normal file
|
@ -0,0 +1 @@
|
|||
0 3 * * * /bin/renew-certificates
|
Loading…
Add table
Add a link
Reference in a new issue