diff --git a/sambro.sh b/sambro.sh index 7069653..640956f 100755 --- a/sambro.sh +++ b/sambro.sh @@ -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/" diff --git a/sambro/etc/init.d/sambro b/sambro/etc/init.d/sambro index e709e3f..4374932 100755 --- a/sambro/etc/init.d/sambro +++ b/sambro/etc/init.d/sambro @@ -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 } diff --git a/sambro/etc/nginx/conf.d/sambro.conf b/sambro/etc/nginx/conf.d/sambro.conf deleted file mode 100644 index 08bf605..0000000 --- a/sambro/etc/nginx/conf.d/sambro.conf +++ /dev/null @@ -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; - } -} diff --git a/sambro/srv/sambro/update-ip.sh b/sambro/srv/sambro/update-ip.sh deleted file mode 100755 index 58f1dcf..0000000 --- a/sambro/srv/sambro/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}:8499\"|" /srv/sambro/conf/000_config.py diff --git a/sambro/srv/sambro/update-url.sh b/sambro/srv/sambro/update-url.sh new file mode 100644 index 0000000..5e6e74b --- /dev/null +++ b/sambro/srv/sambro/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/sambro/conf/000_config.py