From 7f0190e6ab9985ed3aaa026a57014e4cde333728 Mon Sep 17 00:00:00 2001 From: Disassembler Date: Tue, 20 Feb 2018 14:17:16 +0100 Subject: [PATCH] Allow to parametrize Sahana Demo template deployment --- sahana-demo.sh | 8 +++++--- sahana-demo/etc/init.d/sahana-demo | 4 ++-- sahana-demo/srv/sahana-demo/conf/000_config.py | 4 ++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/sahana-demo.sh b/sahana-demo.sh index fb0433b..cc0de04 100755 --- a/sahana-demo.sh +++ b/sahana-demo.sh @@ -1,6 +1,7 @@ #!/bin/sh SOURCE_DIR=$(realpath $(dirname "${0}"))/sahana-demo +export TEMPLATE=${TEMPLATE:-"default"} # Check prerequisites docker image ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh @@ -12,10 +13,10 @@ export SAHANADEMO_PWD=$(head -c 18 /dev/urandom | base64) envsubst <${SOURCE_DIR}/createdb.sql | docker exec -i postgres psql # Prepare persistent directory structure -mkdir -p /srv/sahana-demo/conf /srv/sahana-demo/data/databases /srv/sahana-demo/data/uploads /srv/sahana-demo/data/default +mkdir -p /srv/sahana-demo/conf /srv/sahana-demo/data/databases /srv/sahana-demo/data/uploads /srv/sahana-demo/data/${TEMPLATE} chown -R 8001:8001 /srv/sahana-demo/conf /srv/sahana-demo/data docker run --rm -v /srv/sahana-demo/conf:/mnt/conf sahana cp -rp /srv/web2py/applications/eden/models/. /mnt/conf -docker run --rm -v /srv/sahana-demo/data/default:/mnt/data sahana cp -rp /srv/web2py/applications/eden/modules/templates/default/. /mnt/data +docker run --rm -v /srv/sahana-demo/data/${TEMPLATE}:/mnt/data sahana cp -rp /srv/web2py/applications/eden/modules/templates/${TEMPLATE}/. /mnt/data # Configure Sahana export SAHANADEMO_HMAC=$(head -c 18 /dev/urandom | base64) @@ -30,7 +31,8 @@ docker run --rm -h sahana-demo --link postgres -v /srv/sahana-demo/conf:/srv/web rm /tmp/masterUsers.csv # Create Sahana service -cp ${SOURCE_DIR}/etc/init.d/sahana-demo /etc/init.d/sahana-demo +envsubst <${SOURCE_DIR}/etc/init.d/sahana-demo >/etc/init.d/sahana-demo +chmod +x /etc/init.d/sahana-demo rc-update add sahana-demo service sahana-demo start diff --git a/sahana-demo/etc/init.d/sahana-demo b/sahana-demo/etc/init.d/sahana-demo index 863c4bc..82fd49b 100755 --- a/sahana-demo/etc/init.d/sahana-demo +++ b/sahana-demo/etc/init.d/sahana-demo @@ -1,6 +1,6 @@ #!/sbin/openrc-run -description="Sahana Eden Development docker container" +description="Sahana Eden Demo docker container" depend() { need docker net postgres @@ -19,7 +19,7 @@ start() { --link postgres \ -p 127.0.0.1:8098:8001 \ -v /srv/sahana-demo/conf:/srv/web2py/applications/eden/models \ - -v /srv/sahana-demo/data/default:/srv/web2py/applications/eden/modules/templates/default \ + -v /srv/sahana-demo/data/${TEMPLATE}:/srv/web2py/applications/eden/modules/templates/${TEMPLATE} \ -v /srv/sahana-demo/data/databases:/srv/web2py/applications/eden/databases \ -v /srv/sahana-demo/data/uploads:/srv/web2py/applications/eden/uploads \ sahana diff --git a/sahana-demo/srv/sahana-demo/conf/000_config.py b/sahana-demo/srv/sahana-demo/conf/000_config.py index 0d661c1..4a164a9 100644 --- a/sahana-demo/srv/sahana-demo/conf/000_config.py +++ b/sahana-demo/srv/sahana-demo/conf/000_config.py @@ -23,7 +23,7 @@ FINISHED_EDITING_CONFIG_FILE = True # - Workflows # - Theme # - note that you should restart your web2py after changing this setting -settings.base.template = "default" +settings.base.template = "${TEMPLATE}" # Database settings # Uncomment to use a different database, other than sqlite @@ -236,7 +236,7 @@ settings.import_template() # e.g. #settings.base.system_name = T("Sahana TEST") #settings.base.prepopulate = ("MY_TEMPLATE_ONLY") -settings.base.prepopulate += ("default", "default/users") +settings.base.prepopulate += ("${TEMPLATE}", "default/users") #settings.base.theme = "default" #settings.L10n.default_language = "en" #settings.security.policy = 7 # Organisation-ACLs