Skip to content

Commit

Permalink
Adjust config handling on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-arthur committed Jul 20, 2024
1 parent 551dea4 commit 7285527
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,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\
&& if test -f /home/config.inc.php; then cp /home/config.inc.php config.inc.php; echo "Using stored config in /home/config.inc.php"; else cp config.TEMPLATE.inc.php config.inc.php; echo "Copying config from tepmlate"; fi \
&& chown -R apache:apache /var/www/* \
# Prepare freefont for captcha
&& ln -s /usr/share/fonts/TTF/FreeSerif.ttf /usr/share/fonts/FreeSerif.ttf \
Expand Down
35 changes: 19 additions & 16 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,27 @@ eval $(printenv | sed -n "s/^\([^=]\+\)=\(.*\)$/export \1=\2/p" | sed 's/"/\\\"/
echo "Starting SSH ..."
/usr/sbin/sshd

chmod +x /usr/local/bin/ojs-variable
# Temporary fix for error in ojs-variable (fixed here https://gitlab.com/pkp-org/docker/ojs/-/commit/f4f33f370e7c765b599868f0ca701898c875b47f, but not in stable-3_4_0 branch)
sed -i 's:/tmp/ojs.config.inc.php:/tmp/config.inc.php:' /usr/local/bin/ojs-variable
# Only set config variables if this is a fresh install (Note: these vars might be incomplete)
if ! test -f /home/config.inc.php; then
chmod +x /usr/local/bin/ojs-variable
# Temporary fix for error in ojs-variable (fixed here https://gitlab.com/pkp-org/docker/ojs/-/commit/f4f33f370e7c765b599868f0ca701898c875b47f, but not in stable-3_4_0 branch)
sed -i 's:/tmp/ojs.config.inc.php:/tmp/config.inc.php:' /usr/local/bin/ojs-variable

# 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..."
declare -A configVariable
configVariable["base_url"]=$WEBSITE_HOSTNAME
configVariable["restful_urls"]="On"
configVariable["host"]=$OJS_DB_HOST
configVariable["username"]=$OJS_DB_USER
configVariable["password"]=$OJS_DB_PASSWORD
configVariable["name"]=$OJS_DB_NAME
configVariable["time_zone"]=$TIME_ZONE
# 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..."
declare -A configVariable
configVariable["base_url"]=$WEBSITE_HOSTNAME
configVariable["restful_urls"]="On"
configVariable["host"]=$OJS_DB_HOST
configVariable["username"]=$OJS_DB_USER
configVariable["password"]=$OJS_DB_PASSWORD
configVariable["name"]=$OJS_DB_NAME
configVariable["time_zone"]=$TIME_ZONE

for key in "${!configVariable[@]}"; do
ojs-variable $key ${configVariable[$key]}
done
for key in "${!configVariable[@]}"; do
ojs-variable $key ${configVariable[$key]}
done
fi;

chmod +x /usr/local/bin/ojs-start
ojs-start

0 comments on commit 7285527

Please sign in to comment.