diff --git a/sahana.sh b/sahana.sh index 7d269a3..dbcc362 100755 --- a/sahana.sh +++ b/sahana.sh @@ -26,6 +26,7 @@ chown -R 8001:8001 /srv/sahana/data export SAHANA_HMAC=$(head -c 18 /dev/urandom | base64) envsubst <${SOURCE_DIR}/srv/sahana/conf/000_config.py >/srv/sahana/conf/000_config.py cp ${SOURCE_DIR}/srv/sahana/conf/00_settings.py /srv/sahana/conf/00_settings.py +cp ${SOURCE_DIR}/srv/sahana/update-ip.sh /srv/sahana/update-ip.sh export SAHANA_ADMIN_USER=admin@example.com export SAHANA_ADMIN_PWD=$(head -c 12 /dev/urandom | base64) envsubst <${SOURCE_DIR}/srv/sahana/data/Spotter/masterUsers.csv >/srv/sahana/data/Spotter/masterUsers.csv diff --git a/sahana/etc/init.d/sahana b/sahana/etc/init.d/sahana index 166307b..51eddfd 100755 --- a/sahana/etc/init.d/sahana +++ b/sahana/etc/init.d/sahana @@ -7,6 +7,10 @@ depend() { use dns logger netmount postfix } +start_pre() { + /srv/sahana/update-ip.sh +} + start() { /usr/bin/docker run -d --rm \ --name sahana \ diff --git a/sahana/srv/sahana/conf/000_config.py b/sahana/srv/sahana/conf/000_config.py index 77eb7b7..f10c4ff 100644 --- a/sahana/srv/sahana/conf/000_config.py +++ b/sahana/srv/sahana/conf/000_config.py @@ -50,7 +50,7 @@ settings.gis.spatialdb = True #settings.base.system_name = T("Sahana Eden Humanitarian Management Platform") #settings.base.system_name_short = T("Sahana Eden") # Set this to the Public URL of the instance -#settings.base.public_url = "http://127.0.0.1:8000" +settings.base.public_url = "http://127.0.0.1" # Switch to "False" in Production for a Performance gain # (need to set to "True" again when Table definitions are changed) diff --git a/sahana/srv/sahana/update-ip.sh b/sahana/srv/sahana/update-ip.sh new file mode 100755 index 0000000..12cd5ed --- /dev/null +++ b/sahana/srv/sahana/update-ip.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +URL=$(ip route get 1 | awk '{print $NF;exit}') +sed -i "s|^settings\.base\.public_url.*|settings.base.public_url = \"https://${URL}:8401\"|" /srv/sahana/conf/000_config.py diff --git a/sambro.sh b/sambro.sh index 2366d50..2b7886c 100755 --- a/sambro.sh +++ b/sambro.sh @@ -20,6 +20,7 @@ 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 diff --git a/sambro/etc/init.d/sambro b/sambro/etc/init.d/sambro index 56dc9bb..e709e3f 100755 --- a/sambro/etc/init.d/sambro +++ b/sambro/etc/init.d/sambro @@ -7,6 +7,10 @@ depend() { use dns logger netmount postfix } +start_pre() { + /srv/sambro/update-ip.sh +} + start() { /usr/bin/docker run -d --rm \ --name sambro \ diff --git a/sambro/srv/sambro/conf/000_config.py b/sambro/srv/sambro/conf/000_config.py index cb18639..5699545 100644 --- a/sambro/srv/sambro/conf/000_config.py +++ b/sambro/srv/sambro/conf/000_config.py @@ -50,7 +50,7 @@ settings.gis.spatialdb = True #settings.base.system_name = T("Sahana Eden Humanitarian Management Platform") #settings.base.system_name_short = T("Sahana Eden") # Set this to the Public URL of the instance -#settings.base.public_url = "http://127.0.0.1:8000" +settings.base.public_url = "http://127.0.0.1" # Switch to "False" in Production for a Performance gain # (need to set to "True" again when Table definitions are changed) diff --git a/sambro/srv/sambro/update-ip.sh b/sambro/srv/sambro/update-ip.sh new file mode 100755 index 0000000..58f1dcf --- /dev/null +++ b/sambro/srv/sambro/update-ip.sh @@ -0,0 +1,4 @@ +#!/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