Include DOMAIN directly in HOST envvar for update-conf.sh, update add-ca-cert

This commit is contained in:
Disassembler 2020-04-10 17:57:42 +02:00
parent 6bab2bda8d
commit 867997b588
No known key found for this signature in database
GPG Key ID: 524BD33A0EE29499
14 changed files with 39 additions and 30 deletions

@ -1 +1 @@
Subproject commit 67f71697fb817348c40e0bebe1434db898dd6d0a
Subproject commit 4989d2f87f148594896a0f9dde2de8844d774efa

View File

@ -5,7 +5,7 @@ import ssl
with open('/etc/ckan-datapusher/add-ca-cert.env') as f:
env = dict(tuple(line.split('=')) for line in f.read().splitlines())
cert = ssl.get_server_certificate((env['DOMAIN'], env['PORT']))
cert = ssl.get_server_certificate((env['HOST'], env['PORT']))
with open('/usr/lib/python2.7/site-packages/requests/cacert.pem', 'a') as f:
f.write(cert)

View File

@ -1,2 +1,2 @@
DOMAIN=ckan.spotter.vm
HOST=ckan.spotter.vm
PORT=443

View File

@ -5,13 +5,16 @@ DATAPUSHER_CONF="${VOLUMES_DIR}/ckan/datapusher_conf"
CKAN_CONF="${VOLUMES_DIR}/ckan/ckan_conf"
# Variables
HOST="${HOST}.${DOMAIN}"
[ "${PORT}" != "443" ] && HOST="${HOST}:${PORT}"
HTTP_HOST="${HOST}"
[ "${PORT}" != "443" ] && HTTP_HOST="${HTTP_HOST}:${PORT}"
# Replacements
sed -i "s|\(^ckan\.site_url = \).*|\1https://${HOST}|" ${CKAN_CONF}/ckan.ini
sed -i "s|\(^ckan\.site_url = \).*|\1https://${HTTP_HOST}|" ${CKAN_CONF}/ckan.ini
sed -i "s|\(^smtp\.mail_from = \).*|\1${EMAIL}|" ${CKAN_CONF}/ckan.ini
sed -i "s|\(^ckanext\.geoview\.gapi_key = \).*|\1${GMAPS_API_KEY}|" ${CKAN_CONF}/ckan.ini
cat <<EOF >${DATAPUSHER_CONF}/add-ca-cert.env
HOST=${HOST}
PORT=${PORT}
EOF
sed -i "s|\(^FROM_EMAIL = \).*|\1'${EMAIL}'|" ${DATAPUSHER_CONF}/datapusher_settings.py

View File

@ -4,7 +4,7 @@
MIFOSX_CONF="${VOLUMES_DIR}/mifosx/mifosx_conf"
# Replacements
sed -i "s|\(^\s\+proxyName=\).*|\1\"${HOST}.${DOMAIN}\"|" ${MIFOSX_CONF}/server.xml
sed -i "s|\(^\s\+proxyName=\).*|\1\"${HOST}\"|" ${MIFOSX_CONF}/server.xml
sed -i "s|\(^\s\+proxyPort=\).*|\1\"${PORT}\"|" ${MIFOSX_CONF}/server.xml
QUERY="UPDATE \`c_external_service_properties\` SET \`value\` = '${EMAIL}' WHERE \`external_service_id\` = 2 and \`name\` LIKE 'username'"

View File

@ -4,8 +4,8 @@
MOTECH_CONF="${VOLUMES_DIR}/motech/motech_conf"
# Variables
HOST="${HOST}.${DOMAIN}"
[ "${PORT}" != "443" ] && HOST="${HOST}:${PORT}"
HTTP_HOST="${HOST}"
[ "${PORT}" != "443" ] && HTTP_HOST="${HTTP_HOST}:${PORT}"
# Replacements
sed -i "s|\(^server\.url=\).*|\1https://${HOST}|" ${MOTECH_CONF}/config/motech-settings.properties
sed -i "s|\(^server\.url=\).*|\1https://${HTTP_HOST}|" ${MOTECH_CONF}/config/motech-settings.properties

View File

@ -1,2 +1,2 @@
DOMAIN=odk.spotter.vm
HOST=odk.spotter.vm
PORT=443

View File

@ -2,8 +2,14 @@
# Volumes
ODK_CONF="${VOLUMES_DIR}/opendatakit/odk_conf"
ODKBUILD_CONF="${VOLUMES_DIR}/opendatakit/odkbuild_conf"
# Replacements
sed -i "s|\(^\s\+proxyName=\).*|\1\"${HOST}.${DOMAIN}\"|" ${ODK_CONF}/server.xml
sed -i "s|\(^\s\+proxyName=\).*|\1\"${HOST}\"|" ${ODK_CONF}/server.xml
sed -i "s|\(^\s\+proxyPort=\).*|\1\"${PORT}\"|" ${ODK_CONF}/server.xml
sed -i "s|\(^security\.server\.securePort=\).*|\1${PORT}|" ${ODK_CONF}/security.properties
cat <<EOF >${ODKBUILD_CONF}/add-ca-cert.env
HOST=${HOST}
PORT=${PORT}
EOF

View File

@ -2,5 +2,5 @@
. /srv/opendatakit-build/add-ca-cert.env
true | openssl s_client -connect ${DOMAIN}:${PORT} | openssl x509 -out /usr/local/share/ca-certificates/opendatakit.crt
true | openssl s_client -connect ${HOST}:${PORT} | openssl x509 -out /usr/local/share/ca-certificates/opendatakit.crt
update-ca-certificates

View File

@ -4,9 +4,9 @@
PANDORA_CONF="${VOLUMES_DIR}/pandora/pandora_conf"
# Variables
HOST="${HOST}.${DOMAIN}"
[ "${PORT}" != "443" ] && HOST="${HOST}:${PORT}"
HTTP_HOST="${HOST}"
[ "${PORT}" != "443" ] && HTTP_HOST="${HTTP_HOST}:${PORT}"
# Replacements
sed -i "s|\(^\s\+\"url\": \).*|\1\"${HOST}\"|" ${PANDORA_CONF}/config.jsonc
sed -i "s|\(^\s\+\"url\": \).*|\1\"${HTTP_HOST}\"|" ${PANDORA_CONF}/config.jsonc
sed -i "s|\(^GOOGLE_API_KEY = \).*|\1'${GMAPS_API_KEY}'|" ${PANDORA_CONF}/local_settings.py

View File

@ -4,11 +4,11 @@
SAHANA_CONF="${VOLUMES_DIR}/sahana-demo/sahana_conf"
# Variables
HOST="${HOST}.${DOMAIN}"
[ "${PORT}" != "443" ] && HOST="${HOST}:${PORT}"
HTTP_HOST="${HOST}"
[ "${PORT}" != "443" ] && HTTP_HOST="${HTTP_HOST}:${PORT}"
# Replacements
sed -i "s|\(^settings\.base\.public_url = \).*|\1\"https://${HOST}\"|" ${SAHANA_CONF}/000_config.py
sed -i "s|\(^settings\.base\.public_url = \).*|\1\"https://${HTTP_HOST}\"|" ${SAHANA_CONF}/000_config.py
sed -i "s|\(^settings\.mail\.sender = \).*|\1\"${EMAIL}\"|" ${SAHANA_CONF}/000_config.py
sed -i "s|\(^settings\.mail\.approver = \).*|\1\"${EMAIL}\"|" ${SAHANA_CONF}/000_config.py
sed -i "s|\(^settings\.gis\.api_google = \).*|\1\"${GMAPS_API_KEY}\"|" ${SAHANA_CONF}/000_config.py

View File

@ -4,11 +4,11 @@
SAHANA_CONF="${VOLUMES_DIR}/sahana/sahana_conf"
# Variables
HOST="${HOST}.${DOMAIN}"
[ "${PORT}" != "443" ] && HOST="${HOST}:${PORT}"
HTTP_HOST="${HOST}"
[ "${PORT}" != "443" ] && HTTP_HOST="${HTTP_HOST}:${PORT}"
# Replacements
sed -i "s|\(^settings\.base\.public_url = \).*|\1\"https://${HOST}\"|" ${SAHANA_CONF}/000_config.py
sed -i "s|\(^settings\.base\.public_url = \).*|\1\"https://${HTTP_HOST}\"|" ${SAHANA_CONF}/000_config.py
sed -i "s|\(^settings\.mail\.sender = \).*|\1\"${EMAIL}\"|" ${SAHANA_CONF}/000_config.py
sed -i "s|\(^settings\.mail\.approver = \).*|\1\"${EMAIL}\"|" ${SAHANA_CONF}/000_config.py
sed -i "s|\(^settings\.gis\.api_google = \).*|\1\"${GMAPS_API_KEY}\"|" ${SAHANA_CONF}/000_config.py

View File

@ -4,11 +4,11 @@
SAHANA_CONF="${VOLUMES_DIR}/sambro/sahana_conf"
# Variables
HOST="${HOST}.${DOMAIN}"
[ "${PORT}" != "443" ] && HOST="${HOST}:${PORT}"
HTTP_HOST="${HOST}"
[ "${PORT}" != "443" ] && HTTP_HOST="${HTTP_HOST}:${PORT}"
# Replacements
sed -i "s|\(^settings\.base\.public_url = \).*|\1\"https://${HOST}\"|" ${SAHANA_CONF}/000_config.py
sed -i "s|\(^settings\.base\.public_url = \).*|\1\"https://${HTTP_HOST}\"|" ${SAHANA_CONF}/000_config.py
sed -i "s|\(^settings\.mail\.sender = \).*|\1\"${EMAIL}\"|" ${SAHANA_CONF}/000_config.py
sed -i "s|\(^settings\.mail\.approver = \).*|\1\"${EMAIL}\"|" ${SAHANA_CONF}/000_config.py
sed -i "s|\(^settings\.gis\.api_google = \).*|\1\"${GMAPS_API_KEY}\"|" ${SAHANA_CONF}/000_config.py

View File

@ -4,12 +4,12 @@
USHAHIDI_CONF="${VOLUMES_DIR}/ushahidi/ushahidi_conf"
# Variables
HOST="${HOST}.${DOMAIN}"
[ "${PORT}" != "443" ] && HOST="${HOST}:${PORT}"
HTTP_HOST="${HOST}"
[ "${PORT}" != "443" ] && HTTP_HOST="${HTTP_HOST}:${PORT}"
# Replacements
sed -i "s|\(^\s\+\"backend_url\": \).*|\1\"https://${HOST}/platform\",|" ${USHAHIDI_CONF}/config.json
API_URL="\"https:\\\/\\\/${HOST}\\\/platform\\\/api\\\/v3\\\/config\\\/data-provider\""
sed -i "s|\(^\s\+\"backend_url\": \).*|\1\"https://${HTTP_HOST}/platform\",|" ${USHAHIDI_CONF}/config.json
API_URL="\"https:\\\/\\\/${HTTP_HOST}\\\/platform\\\/api\\\/v3\\\/config\\\/data-provider\""
QUERY="UPDATE \`config\` SET \`config_value\` = '${API_URL}' WHERE \`group_name\` LIKE 'data-provider' AND \`config_key\` LIKE 'url'"
spoc-container exec ushahidi-mariadb -- mysql -e "${QUERY}" ushahidi