diff --git a/sahana-demo.sh b/sahana-demo.sh index adb7d1b..6ca6482 100755 --- a/sahana-demo.sh +++ b/sahana-demo.sh @@ -20,11 +20,11 @@ docker run --rm -v /srv/sahana-demo/data/${TEMPLATE}:/mnt/data sahana cp -rp /sr # Configure Sahana export SAHANADEMO_HMAC=$(head -c 18 /dev/urandom | base64) -envsubst <${SOURCE_DIR}/srv/sahana-demo/conf/000_config.py >/srv/sahana-demo/conf/000_config.py -cp ${SOURCE_DIR}/srv/sahana-demo/update-ip.sh /srv/sahana-demo/update-ip.sh export SAHANADEMO_ADMIN_USER=admin@example.com export SAHANADEMO_ADMIN_PWD=$(head -c 12 /dev/urandom | base64) +envsubst <${SOURCE_DIR}/srv/sahana-demo/conf/000_config.py >/srv/sahana-demo/conf/000_config.py envsubst <${SOURCE_DIR}/masterUsers.csv >/tmp/masterUsers.csv +cp ${SOURCE_DIR}/srv/sahana-demo/update-url.sh /srv/sahana-demo/update-url.sh # Populate database docker run --rm -h sahana-demo --link postgres -v /srv/sahana-demo/conf:/srv/web2py/applications/eden/models -v /srv/sahana-demo/data/databases:/srv/web2py/applications/eden/databases -v /tmp/masterUsers.csv:/srv/web2py/applications/eden/modules/templates/default/users/masterUsers.csv sahana su - sahana -c "./web2py.py -S eden -M -R applications/eden/static/scripts/tools/noop.py" @@ -36,9 +36,5 @@ chmod +x /etc/init.d/sahana-demo rc-update add sahana-demo service sahana-demo start -# Create nginx app definition -cp ${SOURCE_DIR}/etc/nginx/conf.d/sahana-demo.conf /etc/nginx/conf.d/sahana-demo.conf -service nginx reload - -# Add portal application definition -portal-app-manager sahana-eden-demo "https://{host}:8498/eden/" "${SAHANADEMO_ADMIN_USER}" "${SAHANADEMO_ADMIN_PWD}" +# Add application definition +spotter-appmgr add-app sahana-demo "https://sahana-demo.{host}/eden/" "${SAHANADEMO_ADMIN_USER}" "${SAHANADEMO_ADMIN_PWD}" diff --git a/sahana-demo/etc/init.d/sahana-demo b/sahana-demo/etc/init.d/sahana-demo index 82fd49b..1f400a2 100755 --- a/sahana-demo/etc/init.d/sahana-demo +++ b/sahana-demo/etc/init.d/sahana-demo @@ -7,17 +7,12 @@ depend() { use dns logger netmount postfix } -start_pre() { - /srv/sahana-demo/update-ip.sh -} - start() { /usr/bin/docker run -d --rm \ --name sahana-demo \ -h sahana-demo \ --link postfix \ --link postgres \ - -p 127.0.0.1:8098:8001 \ -v /srv/sahana-demo/conf:/srv/web2py/applications/eden/models \ -v /srv/sahana-demo/data/${TEMPLATE}:/srv/web2py/applications/eden/modules/templates/${TEMPLATE} \ -v /srv/sahana-demo/data/databases:/srv/web2py/applications/eden/databases \ @@ -25,6 +20,10 @@ start() { sahana } +start_post() { + /usr/local/bin/spotter-appmgr update-hosts sahana-demo +} + stop() { /usr/bin/docker stop sahana-demo } diff --git a/sahana-demo/etc/nginx/conf.d/sahana-demo.conf b/sahana-demo/etc/nginx/conf.d/sahana-demo.conf deleted file mode 100644 index d96d4c4..0000000 --- a/sahana-demo/etc/nginx/conf.d/sahana-demo.conf +++ /dev/null @@ -1,11 +0,0 @@ -server { - listen [::]:8898 ipv6only=off; - listen [::]:8498 ssl http2 ipv6only=off; - - access_log /var/log/nginx/sahana-demo.access.log; - error_log /var/log/nginx/sahana-demo.error.log; - - location / { - proxy_pass http://127.0.0.1:8098; - } -} diff --git a/sahana-demo/srv/sahana-demo/update-ip.sh b/sahana-demo/srv/sahana-demo/update-ip.sh deleted file mode 100755 index 84987f3..0000000 --- a/sahana-demo/srv/sahana-demo/update-ip.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -URL=$(ip route get 1 | awk '{print $NF;exit}') -sed -i "s|^settings\.base\.public_url.*|settings.base.public_url = \"https://${URL}:8498\"|" /srv/sahana-demo/conf/000_config.py diff --git a/sahana-demo/srv/sahana-demo/update-url.sh b/sahana-demo/srv/sahana-demo/update-url.sh new file mode 100644 index 0000000..9a1fc4f --- /dev/null +++ b/sahana-demo/srv/sahana-demo/update-url.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +HOST="${1}" +[ "${2}" != "443" ] && HOST="${1}:${2}" + +sed -i "s|^settings\.base\.public_url.*|settings.base.public_url = \"https://${HOST}\"|" /srv/sahana-demo/conf/000_config.py