From 990b564d06eb65ed777b463c80ef0c218200872c Mon Sep 17 00:00:00 2001 From: Disassembler Date: Sun, 1 Sep 2024 11:09:40 +0200 Subject: [PATCH] Make entrypoint setup more granular, optimize s6 --- seeddms/image.d/entrypoint.sh | 18 ++++++++++++++---- .../image.d/etc/services.d/.s6-svscan/finish | 6 ++---- .../image.d/etc/services.d/cron/timeout-kill | 1 + .../image.d/etc/services.d/nginx/timeout-kill | 1 + .../etc/services.d/php-fpm/timeout-kill | 1 + 5 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 seeddms/image.d/etc/services.d/cron/timeout-kill create mode 100644 seeddms/image.d/etc/services.d/nginx/timeout-kill create mode 100644 seeddms/image.d/etc/services.d/php-fpm/timeout-kill diff --git a/seeddms/image.d/entrypoint.sh b/seeddms/image.d/entrypoint.sh index fb23efd..601a753 100755 --- a/seeddms/image.d/entrypoint.sh +++ b/seeddms/image.d/entrypoint.sh @@ -14,16 +14,26 @@ chown -R seeddms:seeddms /srv/seeddms/conf /srv/seeddms/data export PGPASSWORD=${POSTGRES_PASSWORD} DB_EXISTS=$(psql -h "${POSTGRES_HOST}" -Atc "SELECT 1 FROM \"tblVersion\"" "${POSTGRES_DB}" "${POSTGRES_USER}" 2>/dev/null || true) if [ -z "${DB_EXISTS}" ]; then - cat /srv/seeddms/seeddms/install/create_tables-postgres.sql | psql -h "${POSTGRES_HOST}" "${POSTGRES_DB}" "${POSTGRES_USER}" - cat /srv/seeddms/seeddms/install/custom.sql | psql -h "${POSTGRES_HOST}" "${POSTGRES_DB}" "${POSTGRES_USER}" + echo "Populating database..." + cat /srv/seeddms/seeddms/install/create_tables-postgres.sql | psql -h "${POSTGRES_HOST}" "${POSTGRES_DB}" "${POSTGRES_USER}" >/dev/null + cat /srv/seeddms/seeddms/install/custom.sql | psql -h "${POSTGRES_HOST}" "${POSTGRES_DB}" "${POSTGRES_USER}" >/dev/null +fi +# Update admin +if [ -n "${SEEDDMS_ADMIN_USER}" ]; then + psql -h "${POSTGRES_HOST}" -Atc "UPDATE \"tblUsers\" SET login = '${SEEDDMS_ADMIN_USER}' WHERE id = 1" "${POSTGRES_DB}" "${POSTGRES_USER}" >/dev/null +fi +if [ -n "${SEEDDMS_ADMIN_PASSWORD}" ]; then + psql -h "${POSTGRES_HOST}" -Atc "UPDATE \"tblUsers\" SET pwd = MD5('${SEEDDMS_ADMIN_PASSWORD}') WHERE id = 1" "${POSTGRES_DB}" "${POSTGRES_USER}" >/dev/null +fi +if [ -n "${SEEDDMS_ADMIN_EMAIL}" ] ; then + psql -h "${POSTGRES_HOST}" -Atc "UPDATE \"tblUsers\" SET email = '${SEEDDMS_ADMIN_EMAIL}' WHERE id = 1" "${POSTGRES_DB}" "${POSTGRES_USER}" >/dev/null fi -psql -h "${POSTGRES_HOST}" -Atc "UPDATE \"tblUsers\" SET login = '${SEEDDMS_ADMIN_USER}', pwd = MD5('${SEEDDMS_ADMIN_PASSWORD}'), email = '${SEEDDMS_ADMIN_EMAIL}' WHERE id = 1" "${POSTGRES_DB}" "${POSTGRES_USER}" # TODO: Update database # Looks like database schema updates are done only in new minor version (e.g. 6.0.x -> 6.1.x) unset PGPASSWORD # Configure SeedDMS -/usr/bin/php -f /srv/seeddms/settings-from-env-vars.php +php -f /srv/seeddms/settings-from-env-vars.php chown seeddms:seeddms /srv/seeddms/conf/settings.xml # Exec into s6 supervisor diff --git a/seeddms/image.d/etc/services.d/.s6-svscan/finish b/seeddms/image.d/etc/services.d/.s6-svscan/finish index 3b6c8bf..db3885d 100755 --- a/seeddms/image.d/etc/services.d/.s6-svscan/finish +++ b/seeddms/image.d/etc/services.d/.s6-svscan/finish @@ -1,5 +1,3 @@ -#!/bin/execlineb -P +#!/bin/execlineb -/bin/foreground { /bin/s6-svwait -d -t 3000 cron } -/bin/foreground { /bin/s6-svwait -d -t 3000 nginx } -/bin/foreground { /bin/s6-svwait -d -t 3000 php-fpm } +exit 0 diff --git a/seeddms/image.d/etc/services.d/cron/timeout-kill b/seeddms/image.d/etc/services.d/cron/timeout-kill new file mode 100644 index 0000000..13de30f --- /dev/null +++ b/seeddms/image.d/etc/services.d/cron/timeout-kill @@ -0,0 +1 @@ +3000 diff --git a/seeddms/image.d/etc/services.d/nginx/timeout-kill b/seeddms/image.d/etc/services.d/nginx/timeout-kill new file mode 100644 index 0000000..13de30f --- /dev/null +++ b/seeddms/image.d/etc/services.d/nginx/timeout-kill @@ -0,0 +1 @@ +3000 diff --git a/seeddms/image.d/etc/services.d/php-fpm/timeout-kill b/seeddms/image.d/etc/services.d/php-fpm/timeout-kill new file mode 100644 index 0000000..13de30f --- /dev/null +++ b/seeddms/image.d/etc/services.d/php-fpm/timeout-kill @@ -0,0 +1 @@ +3000