From fc99f7f6ab893b6e2c8be2aed74984c6a5a374ee Mon Sep 17 00:00:00 2001 From: Disassembler Date: Tue, 18 Sep 2018 15:18:29 +0200 Subject: [PATCH] Integrate forgotten update-url.sh --- basic/srv/vm/mgr/__init__.py | 2 +- basic/srv/vm/mgr/confupdater.py | 14 +++++++++++++- mifosx/setup/srv/mifosx/update-url.sh | 4 ---- opendatakit/setup/srv/opendatakit/update-url.sh | 5 ----- 4 files changed, 14 insertions(+), 11 deletions(-) delete mode 100755 mifosx/setup/srv/mifosx/update-url.sh delete mode 100755 opendatakit/setup/srv/opendatakit/update-url.sh diff --git a/basic/srv/vm/mgr/__init__.py b/basic/srv/vm/mgr/__init__.py index dd6540c..925babb 100644 --- a/basic/srv/vm/mgr/__init__.py +++ b/basic/srv/vm/mgr/__init__.py @@ -288,7 +288,7 @@ class VMMgr: def update_apps_urls(self): # Update configuration for respective applications - confupdater.update_url(tools.compile_url(self.domain, self.port, None)) + confupdater.update_url(self.domain, self.port) # Restart currently running apps in order to update config and re-register nginx proxy for app in self.conf['apps']: if tools.is_service_started(app): diff --git a/basic/srv/vm/mgr/confupdater.py b/basic/srv/vm/mgr/confupdater.py index 7f98787..68e8f67 100644 --- a/basic/srv/vm/mgr/confupdater.py +++ b/basic/srv/vm/mgr/confupdater.py @@ -1,5 +1,7 @@ # -*- coding: utf-8 -*- +# TODO: Rewrite back to individual files + import os import shutil import subprocess @@ -111,13 +113,23 @@ def update_email(email): query = 'UPDATE `config` SET `config_value` = "\\"{}\\"" WHERE `group_name` LIKE "site" AND `config_key` LIKE "email";'.format(email) run_mysql_query(query, 'ushahidi') -def update_url(host): +def update_url(domain, port): + host = tools.compile_url(domain, port, None) # CKAN if app_exists('ckan'): replace_file_line('/srv/ckan/conf/ckan.ini', 'ckan.site_url = ', 'https://ckan.{}'.format(host)) + # Mifos X + if app_exists('mifosx'): + replace_file_line('/srv/mifosx/conf/server.xml', ' proxyName=', '"{}"'.format(domain)) + replace_file_line('/srv/mifosx/conf/server.xml', ' proxyPort=', '"{}"'.format(port)) # Motech if app_exists('motech'): replace_file_line('/srv/motech/conf/config/motech-settings.properties', 'server.url=', 'https://motech.{}'.format(host)) + # OpenDataKit + if app_exists('opendatakit'): + replace_file_line('/srv/opendatakit/conf/server.xml', ' proxyName=', '"{}"'.format(domain)) + replace_file_line('/srv/opendatakit/conf/server.xml', ' proxyPort=', '"{}"'.format(port)) + replace_file_line('/srv/opendatakit/conf/security.properties', 'security.server.securePort=', port) # Pan.do/ra if app_exists('pandora'): replace_file_line('/srv/pandora/conf/config.jsonc', ' "url": ', '"pandora.{}"'.format(host)) diff --git a/mifosx/setup/srv/mifosx/update-url.sh b/mifosx/setup/srv/mifosx/update-url.sh deleted file mode 100755 index 76e6aa7..0000000 --- a/mifosx/setup/srv/mifosx/update-url.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -sed -i "s|\(^\s\+proxyName\).*|\1=\"${1}\"|g" /srv/mifosx/conf/server.xml -sed -i "s|\(^\s\+proxyPort\).*|\1=\"${2}\"|g" /srv/mifosx/conf/server.xml diff --git a/opendatakit/setup/srv/opendatakit/update-url.sh b/opendatakit/setup/srv/opendatakit/update-url.sh deleted file mode 100755 index 76e59e9..0000000 --- a/opendatakit/setup/srv/opendatakit/update-url.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -sed -i "s|\(^\s\+proxyName\).*|\1=\"${1}\"|g" /srv/opendatakit/conf/server.xml -sed -i "s|\(^\s\+proxyPort\).*|\1=\"${2}\"|g" /srv/opendatakit/conf/server.xml -sed -i "s|^security\.server\.securePort.*|security.server.securePort=${2}|" /srv/opendatakit/conf/security.properties