From d3b6450854d70b269e29efc1146dd32fac051590 Mon Sep 17 00:00:00 2001 From: Tom Wiesing Date: Mon, 18 Jan 2021 10:39:18 +0100 Subject: [PATCH] Add support for an overrides file --- .gitignore | 1 + distillery/.env.sample | 4 ++++ distillery/lib/10_config.sh | 9 +++++++++ distillery/resources/compose/self/.env.sample | 3 +++ distillery/resources/compose/self/docker-compose.yml | 5 +++++ distillery/resources/templates/docker-env/self | 1 + distillery/system_install.sh | 1 + 7 files changed, 24 insertions(+) diff --git a/.gitignore b/.gitignore index 84e40a6..13ac8d0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +/distillery/overrides.json authorized_keys .vagrant .env diff --git a/distillery/.env.sample b/distillery/.env.sample index 538d1b1..d1f689b 100644 --- a/distillery/.env.sample +++ b/distillery/.env.sample @@ -11,6 +11,10 @@ DEFAULT_DOMAIN=localhost.kwarc.info # If you want to change this, set an alternate domain name here. SELF_REDIRECT= +# You can override individual URLS in the homepage. +# Do this by adding URLs (without trailing '/'s) into a JSON file +SELF_OVERRIDES_FILE=/distillery/overrides.json + # The system can support setting up certificate(s) automatically. # It can be enabled by setting an email for certbot certificates. # This email address can be configured here. diff --git a/distillery/lib/10_config.sh b/distillery/lib/10_config.sh index b59c92e..950f52e 100644 --- a/distillery/lib/10_config.sh +++ b/distillery/lib/10_config.sh @@ -204,6 +204,15 @@ if [ -z "$GRAPHDB_ADMIN_PASSWORD" ]; then exit 1; fi; +# The 'SELF_OVERRIDES_FILE' should point to a real json file +if ! is_valid_file "$SELF_OVERRIDES_FILE"; then + log_error "Variable 'SELF_OVERRIDES_FILE' is not a valid file. "; + log_info "The variable is currently set to '$SELF_OVERRIDES_FILE'. " + log_info "You might want to create this file (with contents '{}') to get rid of the error message. " + log_info "Please verify that it is set correctly in '.env'"; + exit 1; +fi; + # flags for graphdb authorization GRAPHDB_AUTH_FLAGS="--user $(printf "admin:%s" "$GRAPHDB_ADMIN_PASSWORD")" diff --git a/distillery/resources/compose/self/.env.sample b/distillery/resources/compose/self/.env.sample index d7eba20..e668e99 100644 --- a/distillery/resources/compose/self/.env.sample +++ b/distillery/resources/compose/self/.env.sample @@ -4,6 +4,9 @@ # The target path to redirect to TARGET=https://gitlab.cs.fau.de/AGFD/wisski-distillery +# path to .json +SELF_OVERRIDES_FILE=/overrides.json + ####################### ### Web Server settings ####################### diff --git a/distillery/resources/compose/self/docker-compose.yml b/distillery/resources/compose/self/docker-compose.yml index 501e02b..6dbff20 100644 --- a/distillery/resources/compose/self/docker-compose.yml +++ b/distillery/resources/compose/self/docker-compose.yml @@ -4,6 +4,8 @@ services: tr: image: tkw01536/tr restart: always + volumes: + - "${OVERRIDES_FILE}:/overrides.json:ro" environment: # port and hostname for this image to use VIRTUAL_HOST: ${VIRTUAL_HOST} @@ -13,6 +15,9 @@ services: LETSENCRYPT_HOST: ${LETSENCRYPT_HOST} LETSENCRYPT_EMAIL: ${LETSENCRYPT_EMAIL} + # the overrides file + OVERRIDES: /overrides.json + # where to redirect to TARGET: ${TARGET} diff --git a/distillery/resources/templates/docker-env/self b/distillery/resources/templates/docker-env/self index 69b4449..f93d03e 100644 --- a/distillery/resources/templates/docker-env/self +++ b/distillery/resources/templates/docker-env/self @@ -4,3 +4,4 @@ LETSENCRYPT_HOST=${LETSENCRYPT_HOST} LETSENCRYPT_EMAIL=${LETSENCRYPT_EMAIL} TARGET=${TARGET} +OVERRIDES_FILE=${OVERRIDES_FILE} diff --git a/distillery/system_install.sh b/distillery/system_install.sh index bdc8214..42ca611 100755 --- a/distillery/system_install.sh +++ b/distillery/system_install.sh @@ -83,6 +83,7 @@ load_template "docker-env/self" \ "LETSENCRYPT_HOST" "${LETSENCRYPT_HOST}" \ "LETSENCRYPT_EMAIL" "${LETSENCRYPT_EMAIL}" \ "TARGET" "${SELF_REDIRECT}" \ + "OVERRIDES_FILE" "${SELF_OVERRIDES_FILE}" \ > "$DEPLOY_SELF_DIR/.env"