Unify SAMBRO naming and nginx configuration for spotter-appmgr

This commit is contained in:
Disassembler 2018-03-25 23:20:34 +02:00
parent 73c6793c66
commit bf5ca4c4b4
Signed by: Disassembler
GPG Key ID: 524BD33A0EE29499
5 changed files with 17 additions and 31 deletions

View File

@ -19,13 +19,13 @@ docker run --rm -v /srv/sambro/data/SAMBRO:/mnt/data sahana cp -rp /srv/web2py/a
# Configure SAMBRO
export SAMBRO_HMAC=$(head -c 18 /dev/urandom | base64)
envsubst <${SOURCE_DIR}/srv/sambro/conf/000_config.py >/srv/sambro/conf/000_config.py
cp ${SOURCE_DIR}/srv/sambro/update-ip.sh /srv/sambro/update-ip.sh
cp ${SOURCE_DIR}/srv/sambro/conf/00_settings.py /srv/sambro/conf/00_settings.py
cp ${SOURCE_DIR}/srv/sambro/data/SAMBRO/config.py /srv/sambro/data/SAMBRO/config.py
export SAMBRO_ADMIN_USER=admin@example.com
export SAMBRO_ADMIN_PWD=$(head -c 12 /dev/urandom | base64)
envsubst <${SOURCE_DIR}/srv/sambro/conf/000_config.py >/srv/sambro/conf/000_config.py
envsubst <${SOURCE_DIR}/masterUsers.csv >/tmp/masterUsers.csv
cp ${SOURCE_DIR}/srv/sambro/conf/00_settings.py /srv/sambro/conf/00_settings.py
cp ${SOURCE_DIR}/srv/sambro/data/SAMBRO/config.py /srv/sambro/data/SAMBRO/config.py
cp ${SOURCE_DIR}/srv/sambro/update-url.sh /srv/sambro/update-url.sh
# Populate database
docker run --rm -h sambro --link postgres -v /srv/sambro/conf:/srv/web2py/applications/eden/models -v /srv/sambro/data/SAMBRO:/srv/web2py/applications/eden/modules/templates/SAMBRO -v /tmp/masterUsers.csv:/srv/web2py/applications/eden/modules/templates/default/users/masterUsers.csv -v /srv/sambro/data/databases:/srv/web2py/applications/eden/databases sahana su - sahana -c "./web2py.py -S eden -M -R applications/eden/static/scripts/tools/noop.py"
@ -43,10 +43,6 @@ cp ${SOURCE_DIR}/etc/init.d/sambro /etc/init.d/sambro
rc-update add sambro
service sambro start
# Create nginx app definition
cp ${SOURCE_DIR}/etc/nginx/conf.d/sambro.conf /etc/nginx/conf.d/sambro.conf
service nginx reload
# Add portal application definition
portal-app-manager sambro "https://{host}:8499/eden/" "${SAMBRO_ADMIN_USER}" "${SAMBRO_ADMIN_PWD}"
portal-app-manager sambro-mobile -p clienturl "http://{host}:8899/eden/"
# Add application definition
spotter-appmgr add-app sambro "https://sambro.{host}/eden/" "${SAMBRO_ADMIN_USER}" "${SAMBRO_ADMIN_PWD}"
spotter-appmgr add-app sambro-mobile -p clienturl "https://sambro.{host}/eden/"

View File

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

View File

@ -1,11 +0,0 @@
server {
listen [::]:8899 ipv6only=off;
listen [::]:8499 ssl http2 ipv6only=off;
access_log /var/log/nginx/sambro.access.log;
error_log /var/log/nginx/sambro.error.log;
location / {
proxy_pass http://127.0.0.1:8099;
}
}

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}:8499\"|" /srv/sambro/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/sambro/conf/000_config.py