Unify Sahana Demo naming and nginx configuration for spotter-appmgr

This commit is contained in:
Disassembler 2018-03-25 23:20:08 +02:00
parent 3cf4d8ec1f
commit 73c6793c66
Signed by: Disassembler
GPG Key ID: 524BD33A0EE29499
5 changed files with 14 additions and 28 deletions

View File

@ -20,11 +20,11 @@ docker run --rm -v /srv/sahana-demo/data/${TEMPLATE}:/mnt/data sahana cp -rp /sr
# Configure Sahana # Configure Sahana
export SAHANADEMO_HMAC=$(head -c 18 /dev/urandom | base64) 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_USER=admin@example.com
export SAHANADEMO_ADMIN_PWD=$(head -c 12 /dev/urandom | base64) 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 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 # 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" 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 rc-update add sahana-demo
service sahana-demo start service sahana-demo start
# Create nginx app definition # Add application definition
cp ${SOURCE_DIR}/etc/nginx/conf.d/sahana-demo.conf /etc/nginx/conf.d/sahana-demo.conf spotter-appmgr add-app sahana-demo "https://sahana-demo.{host}/eden/" "${SAHANADEMO_ADMIN_USER}" "${SAHANADEMO_ADMIN_PWD}"
service nginx reload
# Add portal application definition
portal-app-manager sahana-eden-demo "https://{host}:8498/eden/" "${SAHANADEMO_ADMIN_USER}" "${SAHANADEMO_ADMIN_PWD}"

View File

@ -7,17 +7,12 @@ depend() {
use dns logger netmount postfix use dns logger netmount postfix
} }
start_pre() {
/srv/sahana-demo/update-ip.sh
}
start() { start() {
/usr/bin/docker run -d --rm \ /usr/bin/docker run -d --rm \
--name sahana-demo \ --name sahana-demo \
-h sahana-demo \ -h sahana-demo \
--link postfix \ --link postfix \
--link postgres \ --link postgres \
-p 127.0.0.1:8098:8001 \
-v /srv/sahana-demo/conf:/srv/web2py/applications/eden/models \ -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/${TEMPLATE}:/srv/web2py/applications/eden/modules/templates/${TEMPLATE} \
-v /srv/sahana-demo/data/databases:/srv/web2py/applications/eden/databases \ -v /srv/sahana-demo/data/databases:/srv/web2py/applications/eden/databases \
@ -25,6 +20,10 @@ start() {
sahana sahana
} }
start_post() {
/usr/local/bin/spotter-appmgr update-hosts sahana-demo
}
stop() { stop() {
/usr/bin/docker stop sahana-demo /usr/bin/docker stop sahana-demo
} }

View File

@ -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;
}
}

View File

@ -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

View File

@ -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