From e98444c8a73992ab04f50e05943f182a9b11407b Mon Sep 17 00:00:00 2001 From: Arthur Wang Date: Sun, 8 Sep 2024 19:35:58 -0400 Subject: [PATCH] Fix saved config --- Dockerfile | 8 +++----- entrypoint.sh | 23 +++++++++++++---------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/Dockerfile b/Dockerfile index b3381e1..57449be 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,8 @@ ENV COMPOSER_ALLOW_SUPERUSER=1 \ OJS_VERSION=stable-3_4_0 \ OJS_CLI_INSTALL="1" \ OJS_WEB_CONF="/etc/apache2/conf.d/ojs.conf" \ - OJS_CONF="/var/www/html/config.inc.php" + OJS_CONF="/var/www/html/config.inc.php" \ + SAVED_OJS_CONF="/home/config.inc.php" # PHP_INI_DIR to be symmetrical with official php docker image ENV PHP_INI_DIR /etc/php/8.1 @@ -108,10 +109,7 @@ RUN set -xe \ && NODE_OPTIONS=--openssl-legacy-provider npm run build \ # Create directories && mkdir -p /var/www/files /run/apache2 \ - && if test -f /home/config.inc.php; then \ - cp /home/config.inc.php config.inc.php; \ - else cp config.TEMPLATE.inc.php config.inc.php; \ - fi\ + && cp config.TEMPLATE.inc.php config.inc.php \ && chown -R apache:apache /var/www/* \ # Prepare freefont for captcha && ln -s /usr/share/fonts/TTF/FreeSerif.ttf /usr/share/fonts/FreeSerif.ttf \ diff --git a/entrypoint.sh b/entrypoint.sh index 824ea78..66ebad2 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -18,12 +18,17 @@ chown apache /home/files chgrp apache /home/files declare -A configVariable -if ! test -f /home/config.inc.php; then +if [ -f $SAVED_OJS_CONF ] +then + echo "Using existing config.inc.php from /home/config.inc.php" + cp $SAVED_OJS_CONF $OJS_CONF +else # Set config variables using env variables https://github.com/pkp/ojs/blob/main/config.TEMPLATE.inc.php - echo "Updating OJS config based on env variables..." + echo "No existing config in /home. Updating OJS config based on env variables..." # General configVariable["installed"]="On" - configVariable["base_url"]=$WEBSITE_HOSTNAME + # configVariable["base_url"]=$WEBSITE_HOSTNAME + configVariable["base_url"]="https://submissions.post45.org" configVariable["time_zone"]=$TIME_ZONE configVariable["restful_urls"]="On" # Database @@ -49,13 +54,11 @@ if ! test -f /home/config.inc.php; then configVariable["default_envelope_sender"]="no-reply@post45.org" # OAI configVariable["oai"]="Off" + for key in "${!configVariable[@]}"; do + ojs-variable $key ${configVariable[$key]} + done + cp $OJS_CONF $SAVED_OJS_CONF fi -for key in "${!configVariable[@]}"; do - ojs-variable $key ${configVariable[$key]} -done - chmod +x /usr/local/bin/ojs-start -ojs-start -# Note: Fresh installs are async, so /home/config.inc.php may not be correct -cp config.inc.php /home/config.inc.php \ No newline at end of file +ojs-start \ No newline at end of file