Modify app config only when the app is installed
This commit is contained in:
parent
86e411df12
commit
81519dcca4
3
basic.sh
3
basic.sh
@ -59,5 +59,4 @@ service docker start
|
|||||||
docker build -t alpine ${SOURCE_DIR}
|
docker build -t alpine ${SOURCE_DIR}
|
||||||
|
|
||||||
# Set dummy host and generate related files
|
# Set dummy host and generate related files
|
||||||
# Note: This will fail with an exception due to nonexistant application files. The exception can be ignored
|
spotter-appmgr update-host spotter.vm 443
|
||||||
spotter-appmgr update-host spotter.vm 443 || true
|
|
||||||
|
@ -33,72 +33,102 @@ def run_mysql_query(query, database):
|
|||||||
if not maria_started:
|
if not maria_started:
|
||||||
tools.stop_service('mariadb')
|
tools.stop_service('mariadb')
|
||||||
|
|
||||||
|
def app_exists(app):
|
||||||
|
return os.path.exists(os.path.join('/srv/', app))
|
||||||
|
|
||||||
def update_gmaps_api_key(api_key):
|
def update_gmaps_api_key(api_key):
|
||||||
# CKAN
|
# CKAN
|
||||||
|
if app_exists('ckan'):
|
||||||
replace_file_line('/srv/ckan/conf/ckan.ini', 'ckanext.geoview.gapi_key = ', api_key)
|
replace_file_line('/srv/ckan/conf/ckan.ini', 'ckanext.geoview.gapi_key = ', api_key)
|
||||||
# Crisis Cleanup
|
# Crisis Cleanup
|
||||||
|
if app_exists('crisiscleanup'):
|
||||||
replace_file_line('/srv/crisiscleanup/conf/boot.rb', 'ENV[\'GOOGLE_MAPS_API_KEY\'] = ', api_key)
|
replace_file_line('/srv/crisiscleanup/conf/boot.rb', 'ENV[\'GOOGLE_MAPS_API_KEY\'] = ', api_key)
|
||||||
# Pan.do/ra
|
# Pan.do/ra
|
||||||
|
if app_exists('pandora'):
|
||||||
replace_file_line('/srv/pandora/conf/local_settings.py', 'GOOGLE_API_KEY = ', '\'{}\''.format(api_key))
|
replace_file_line('/srv/pandora/conf/local_settings.py', 'GOOGLE_API_KEY = ', '\'{}\''.format(api_key))
|
||||||
# Sahana
|
# Sahana
|
||||||
|
if app_exists('sahana'):
|
||||||
replace_file_line('/srv/sahana/conf/000_config.py', 'settings.gis.api_google = ', '"{}"'.format(api_key))
|
replace_file_line('/srv/sahana/conf/000_config.py', 'settings.gis.api_google = ', '"{}"'.format(api_key))
|
||||||
# Sahana Demo
|
# Sahana Demo
|
||||||
|
if app_exists('sahana-demo'):
|
||||||
replace_file_line('/srv/sahana-demo/conf/000_config.py', 'settings.gis.api_google = ', '"{}"'.format(api_key))
|
replace_file_line('/srv/sahana-demo/conf/000_config.py', 'settings.gis.api_google = ', '"{}"'.format(api_key))
|
||||||
# SAMBRO
|
# SAMBRO
|
||||||
|
if app_exists('sambro'):
|
||||||
replace_file_line('/srv/sambro/conf/000_config.py', 'settings.gis.api_google = ', '"{}"'.format(api_key))
|
replace_file_line('/srv/sambro/conf/000_config.py', 'settings.gis.api_google = ', '"{}"'.format(api_key))
|
||||||
# Sigmah
|
# Sigmah
|
||||||
|
if app_exists('sigmah'):
|
||||||
replace_file_line('/srv/sigmah/conf/sigmah.properties', 'maps.key=', api_key)
|
replace_file_line('/srv/sigmah/conf/sigmah.properties', 'maps.key=', api_key)
|
||||||
# Ushahidi
|
# Ushahidi
|
||||||
|
if app_exists('ushahidi'):
|
||||||
replace_file_line('/srv/ushahidi/conf/config.json', ' "google_analytics_id": ', '"{}"'.format(api_key))
|
replace_file_line('/srv/ushahidi/conf/config.json', ' "google_analytics_id": ', '"{}"'.format(api_key))
|
||||||
|
|
||||||
def update_email(email):
|
def update_email(email):
|
||||||
# CKAN
|
# CKAN
|
||||||
|
if app_exists('ckan'):
|
||||||
replace_file_line('/srv/ckan/conf/ckan.ini', 'smtp.mail_from = ', email)
|
replace_file_line('/srv/ckan/conf/ckan.ini', 'smtp.mail_from = ', email)
|
||||||
replace_file_line('/srv/ckan-datapusher/conf/datapusher_settings.py', 'FROM_EMAIL = ', '\'{}\''.format(email))
|
replace_file_line('/srv/ckan-datapusher/conf/datapusher_settings.py', 'FROM_EMAIL = ', '\'{}\''.format(email))
|
||||||
# Crisis Cleanup
|
# Crisis Cleanup
|
||||||
|
if app_exists('crisiscleanup'):
|
||||||
replace_file_line('/srv/crisiscleanup/conf/initializers/devise.rb', ' config.mailer_sender = ', '\'{}\''.format(email))
|
replace_file_line('/srv/crisiscleanup/conf/initializers/devise.rb', ' config.mailer_sender = ', '\'{}\''.format(email))
|
||||||
# CTS
|
# CTS
|
||||||
|
if app_exists('cts'):
|
||||||
replace_file_line('/srv/cts/conf/spotter.py', 'SERVER_EMAIL = ', '\'{}\''.format(email))
|
replace_file_line('/srv/cts/conf/spotter.py', 'SERVER_EMAIL = ', '\'{}\''.format(email))
|
||||||
# GNU Health
|
# GNU Health
|
||||||
|
if app_exists('gnuhealth'):
|
||||||
replace_file_line('/srv/gnuhealth/conf/trytond.conf', 'from = ', email)
|
replace_file_line('/srv/gnuhealth/conf/trytond.conf', 'from = ', email)
|
||||||
# KanBoard
|
# KanBoard
|
||||||
|
if app_exists('kanboard'):
|
||||||
replace_file_line('/srv/kanboard/conf/config.php', 'define(\'MAIL_FROM\', ', '\'{}\');'.format(email))
|
replace_file_line('/srv/kanboard/conf/config.php', 'define(\'MAIL_FROM\', ', '\'{}\');'.format(email))
|
||||||
# Mifos X
|
# Mifos X
|
||||||
|
if app_exists('mifosx'):
|
||||||
query = 'UPDATE `c_external_service_properties` SET `value` = "{}" WHERE `external_service_id` = 2 and `name` LIKE "username";'.format(email)
|
query = 'UPDATE `c_external_service_properties` SET `value` = "{}" WHERE `external_service_id` = 2 and `name` LIKE "username";'.format(email)
|
||||||
run_mysql_query(query, 'mifostenant-default')
|
run_mysql_query(query, 'mifostenant-default')
|
||||||
# Sahana
|
# Sahana
|
||||||
|
if app_exists('sahana'):
|
||||||
replace_file_line('/srv/sahana/conf/000_config.py', 'settings.mail.sender = ', '"{}"'.format(email))
|
replace_file_line('/srv/sahana/conf/000_config.py', 'settings.mail.sender = ', '"{}"'.format(email))
|
||||||
replace_file_line('/srv/sahana/conf/000_config.py', 'settings.mail.approver = ', '"{}"'.format(email))
|
replace_file_line('/srv/sahana/conf/000_config.py', 'settings.mail.approver = ', '"{}"'.format(email))
|
||||||
# Sahana Demo
|
# Sahana Demo
|
||||||
|
if app_exists('sahana-demo'):
|
||||||
replace_file_line('/srv/sahana-demo/conf/000_config.py', 'settings.mail.sender = ', '"{}"'.format(email))
|
replace_file_line('/srv/sahana-demo/conf/000_config.py', 'settings.mail.sender = ', '"{}"'.format(email))
|
||||||
replace_file_line('/srv/sahana-demo/conf/000_config.py', 'settings.mail.approver = ', '"{}"'.format(email))
|
replace_file_line('/srv/sahana-demo/conf/000_config.py', 'settings.mail.approver = ', '"{}"'.format(email))
|
||||||
# SAMBRO
|
# SAMBRO
|
||||||
|
if app_exists('sambro'):
|
||||||
replace_file_line('/srv/sambro/conf/000_config.py', 'settings.mail.sender = ', '"{}"'.format(email))
|
replace_file_line('/srv/sambro/conf/000_config.py', 'settings.mail.sender = ', '"{}"'.format(email))
|
||||||
replace_file_line('/srv/sambro/conf/000_config.py', 'settings.mail.approver = ', '"{}"'.format(email))
|
replace_file_line('/srv/sambro/conf/000_config.py', 'settings.mail.approver = ', '"{}"'.format(email))
|
||||||
# SeedDMS
|
# SeedDMS
|
||||||
|
if app_exists('seeddms'):
|
||||||
replace_file_line('/srv/seeddms/conf/settings.xml', ' <smtp smtpServer="postfix" smtpPort="25" smtpSendFrom=', '"{}" smtpUser="" smtpPassword=""/>'.format(email))
|
replace_file_line('/srv/seeddms/conf/settings.xml', ' <smtp smtpServer="postfix" smtpPort="25" smtpSendFrom=', '"{}" smtpUser="" smtpPassword=""/>'.format(email))
|
||||||
# Sigmah
|
# Sigmah
|
||||||
|
if app_exists('sigmah'):
|
||||||
replace_file_line('/srv/sigmah/conf/sigmah.properties', 'mail.from.address=', email)
|
replace_file_line('/srv/sigmah/conf/sigmah.properties', 'mail.from.address=', email)
|
||||||
replace_file_line('/srv/sigmah/conf/sigmah.properties', 'mail.support.to=', email)
|
replace_file_line('/srv/sigmah/conf/sigmah.properties', 'mail.support.to=', email)
|
||||||
# Ushahidi
|
# Ushahidi
|
||||||
|
if app_exists('ushahidi'):
|
||||||
email_json = '{\"incoming_type\":\"IMAP\",\"incoming_server\":\"localhost\",\"incoming_port\":143,\"incoming_security\":\"None\",\"incoming_username\":\"{}\",\"incoming_password\":\"password\",\"outgoing_type\":\"SMTP\",\"outgoing_server\":\"postfix\",\"outgoing_port\":25,\"outgoing_security\":\"None\",\"outgoing_username\":\"{}\",\"outgoing_password\":\"password\",\"from\":\"{}\",\"from_name\":\"Ushahidi\"}'
|
email_json = '{\"incoming_type\":\"IMAP\",\"incoming_server\":\"localhost\",\"incoming_port\":143,\"incoming_security\":\"None\",\"incoming_username\":\"{}\",\"incoming_password\":\"password\",\"outgoing_type\":\"SMTP\",\"outgoing_server\":\"postfix\",\"outgoing_port\":25,\"outgoing_security\":\"None\",\"outgoing_username\":\"{}\",\"outgoing_password\":\"password\",\"from\":\"{}\",\"from_name\":\"Ushahidi\"}'
|
||||||
query = 'UPDATE `config` SET `config_value` = "{}" WHERE `group_name` LIKE "data-provider" AND `config_key` LIKE "email";'.format(email_json)
|
query = 'UPDATE `config` SET `config_value` = "{}" WHERE `group_name` LIKE "data-provider" AND `config_key` LIKE "email";'.format(email_json)
|
||||||
run_mysql_query(query, 'ushahidi')
|
run_mysql_query(query, 'ushahidi')
|
||||||
|
|
||||||
def update_url(host):
|
def update_url(host):
|
||||||
# CKAN
|
# CKAN
|
||||||
|
if app_exists('ckan'):
|
||||||
replace_file_line('/srv/ckan/conf/ckan.ini', 'ckan.site_url = ', 'https://ckan.{}'.format(host))
|
replace_file_line('/srv/ckan/conf/ckan.ini', 'ckan.site_url = ', 'https://ckan.{}'.format(host))
|
||||||
# Motech
|
# Motech
|
||||||
|
if app_exists('motech'):
|
||||||
replace_file_line('/srv/motech/conf/config/motech-settings.properties', 'server.url=', 'https://motech.{}'.format(host))
|
replace_file_line('/srv/motech/conf/config/motech-settings.properties', 'server.url=', 'https://motech.{}'.format(host))
|
||||||
# Pan.do/ra
|
# Pan.do/ra
|
||||||
|
if app_exists('pandora'):
|
||||||
replace_file_line('/srv/pandora/conf/config.jsonc', ' "url": ', '"pandora.{}"'.format(host))
|
replace_file_line('/srv/pandora/conf/config.jsonc', ' "url": ', '"pandora.{}"'.format(host))
|
||||||
# Sahana
|
# Sahana
|
||||||
|
if app_exists('sahana'):
|
||||||
replace_file_line('/srv/sahana/conf/000_config.py', 'settings.base.public_url = ', '"https://sahana.{}"'.format(host))
|
replace_file_line('/srv/sahana/conf/000_config.py', 'settings.base.public_url = ', '"https://sahana.{}"'.format(host))
|
||||||
# Sahana Demo
|
# Sahana Demo
|
||||||
|
if app_exists('sahana-demo'):
|
||||||
replace_file_line('/srv/sahana-demo/conf/000_config.py', 'settings.base.public_url = ', '"https://sahana-demo.{}"'.format(host))
|
replace_file_line('/srv/sahana-demo/conf/000_config.py', 'settings.base.public_url = ', '"https://sahana-demo.{}"'.format(host))
|
||||||
# SAMBRO
|
# SAMBRO
|
||||||
|
if app_exists('sambro'):
|
||||||
replace_file_line('/srv/sambro/conf/000_config.py', 'settings.base.public_url = ', '"https://sambro.{}"'.format(host))
|
replace_file_line('/srv/sambro/conf/000_config.py', 'settings.base.public_url = ', '"https://sambro.{}"'.format(host))
|
||||||
# Ushahidi
|
# Ushahidi
|
||||||
|
if app_exists('ushahidi'):
|
||||||
replace_file_line('/srv/ushahidi/conf/config.json', ' "backend_url": ', '"https://ush.{}/platform",'.format(host))
|
replace_file_line('/srv/ushahidi/conf/config.json', ' "backend_url": ', '"https://ush.{}/platform",'.format(host))
|
||||||
api_url = '\"https:\\/\\/ush.{}\\/platform\\/api\\/v3\\/config\\/data-provider\"'
|
api_url = '\"https:\\/\\/ush.{}\\/platform\\/api\\/v3\\/config\\/data-provider\"'
|
||||||
query = 'UPDATE `config` SET `config_value` = "{}" WHERE `group_name` LIKE "data-provider" AND `config_key` LIKE "url";'.format(api_url)
|
query = 'UPDATE `config` SET `config_value` = "{}" WHERE `group_name` LIKE "data-provider" AND `config_key` LIKE "url";'.format(api_url)
|
||||||
|
Loading…
Reference in New Issue
Block a user