From 0620c6ebd02c120e9a2f3a57765292348d5c4176 Mon Sep 17 00:00:00 2001 From: Disassembler Date: Tue, 8 Mar 2022 13:52:48 +0100 Subject: [PATCH] Use different way of os.getenv defaults, add mail login --- .env | 1 + docker-compose.yml | 2 -- .../applications/eden/models/000_config.py | 26 +++++++++---------- .../applications/eden/models/000_config.py | 26 +++++++++---------- sahana/image.d/etc/sudoers.d/sahana | 1 + .../applications/eden/models/000_config.py | 26 +++++++++---------- 6 files changed, 41 insertions(+), 41 deletions(-) diff --git a/.env b/.env index 378f510..b2525a1 100644 --- a/.env +++ b/.env @@ -8,6 +8,7 @@ SAHANA_ADMIN_USER=admin SAHANA_ADMIN_PASSWORD=sahana SAHANA_MAIL_HOST=127.0.0.1:25 +SAHANA_MAIL_LOGIN=username:password SAHANA_MAIL_SENDER='Sahana' SAHANA_MAIL_APPROVER=useradmin@example.org diff --git a/docker-compose.yml b/docker-compose.yml index 7670265..eb2a0a2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,7 +15,6 @@ services: ports: - 8080:8080 volumes: - - sahana_models:/srv/web2py/applications/eden/models - sahana_databases:/srv/web2py/applications/eden/databases - sahana_errors:/srv/web2py/applications/eden/errors - sahana_sessions:/srv/web2py/applications/eden/sessions @@ -32,7 +31,6 @@ services: - postgres_data:/var/lib/postgresql/data volumes: - sahana_models: sahana_databases: sahana_errors: sahana_sessions: diff --git a/sahana-sambro/image.d/srv/web2py/applications/eden/models/000_config.py b/sahana-sambro/image.d/srv/web2py/applications/eden/models/000_config.py index 32f866c..f2dbd16 100644 --- a/sahana-sambro/image.d/srv/web2py/applications/eden/models/000_config.py +++ b/sahana-sambro/image.d/srv/web2py/applications/eden/models/000_config.py @@ -32,17 +32,17 @@ settings.base.template = "SAMBRO" settings.database.db_type = "postgres" #settings.database.db_type = "mysql" # Uncomment to use a different host -settings.database.host = os.getenv("POSTGRES_HOST", "localhost") +settings.database.host = os.getenv("POSTGRES_HOST") or "localhost" # Uncomment to use a different port #settings.database.port = 3306 #settings.database.port = 5432 # Uncomment to select a different name for your database -settings.database.database = os.getenv("POSTGRES_DB", "sahana") +settings.database.database = os.getenv("POSTGRES_DB") or "sahana" # Uncomment to select a different username for your database -settings.database.username = os.getenv("POSTGRES_USER", "sahana") +settings.database.username = os.getenv("POSTGRES_USER") or "sahana" # Uncomment to set the password # NB Web2Py doesn't like passwords with an @ in them -settings.database.password = os.getenv("POSTGRES_PASSWORD", "password") +settings.database.password = os.getenv("POSTGRES_PASSWORD") or "password" # Uncomment to use a different pool size #settings.database.pool_size = 30 # Do we have a spatial DB available? (currently supports PostGIS. Spatialite to come.) @@ -52,7 +52,7 @@ settings.gis.spatialdb = True settings.base.system_name = T("Sahana Alerting and Messaging Broker") settings.base.system_name_short = T("SAMBRO") # Set this to the Public URL of the instance -settings.base.public_url = os.getenv("SAHANA_PUBLIC_URL", "http://127.0.0.1:8080") +settings.base.public_url = os.getenv("SAHANA_PUBLIC_URL") or "http://127.0.0.1:8080" # Switch to "False" in Production for a Performance gain # (need to set to "True" again when Table definitions are changed) @@ -87,7 +87,7 @@ settings.base.debug = True # This setting should be changed _before_ registering the 1st user # - should happen automatically if installing using supported scripts -settings.auth.hmac_key = os.getenv("SAHANA_HMAC_KEY", "akeytochange") +settings.auth.hmac_key = os.getenv("SAHANA_HMAC_KEY") or "akeytochange" # If using Masterkey Authentication, then set this to a deployment-specific 32 char string: #settings.auth.masterkey_app_key = "randomstringrandomstringrandomstring" @@ -97,18 +97,18 @@ settings.auth.hmac_key = os.getenv("SAHANA_HMAC_KEY", "akeytochange") # Email settings # Outbound server -settings.mail.server = os.getenv("SAHANA_MAIL_HOST", "127.0.0.1:25") +settings.mail.server = os.getenv("SAHANA_MAIL_HOST") or "127.0.0.1:25" #settings.mail.tls = True # Useful for Windows Laptops: # https://www.google.com/settings/security/lesssecureapps #settings.mail.server = "smtp.gmail.com:587" -#settings.mail.tls = True -#settings.mail.login = "username:password" +settings.mail.tls = True +settings.mail.login = os.getenv("SAHANA_MAIL_LOGIN") or False # From Address - until this is set, no mails can be sent -settings.mail.sender = os.getenv("SAHANA_MAIL_SENDER", "'Sahana' ") +settings.mail.sender = os.getenv("SAHANA_MAIL_SENDER") or "'Sahana' " # Default email address to which requests to approve new user accounts gets sent # This can be overridden for specific domains/organisations via the auth_domain table -settings.mail.approver = os.getenv("SAHANA_MAIL_APPROVER", "useradmin@example.org") +settings.mail.approver = os.getenv("SAHANA_MAIL_APPROVER") or "useradmin@example.org" # Daily Limit on Sending of emails #settings.mail.limit = 1000 @@ -121,9 +121,9 @@ settings.mail.approver = os.getenv("SAHANA_MAIL_APPROVER", "useradmin@example.or # GetAddress API Key (for GetAddress.io Postcode to Address lookup) #settings.gis.api_getaddress = "" # Google API Key (for Google Maps Layers) -settings.gis.api_google = os.getenv("SAHANA_API_KEY_GOOGLE", "") +settings.gis.api_google = os.getenv("SAHANA_API_KEY_GOOGLE") or "" # OpenWeatherMap API Key (for OpenWeatherMap Layers) -settings.gis.api_openweathermap = os.getenv("SAHANA_API_KEY_OPENWEATHERMAP", "") +settings.gis.api_openweathermap = os.getenv("SAHANA_API_KEY_OPENWEATHERMAP") or "" # GeoNames username #settings.gis.geonames_username = "" diff --git a/sahana-spotter/image.d/srv/web2py/applications/eden/models/000_config.py b/sahana-spotter/image.d/srv/web2py/applications/eden/models/000_config.py index 01e2430..96d8c75 100644 --- a/sahana-spotter/image.d/srv/web2py/applications/eden/models/000_config.py +++ b/sahana-spotter/image.d/srv/web2py/applications/eden/models/000_config.py @@ -32,17 +32,17 @@ settings.base.template = "Spotter" settings.database.db_type = "postgres" #settings.database.db_type = "mysql" # Uncomment to use a different host -settings.database.host = os.getenv("POSTGRES_HOST", "localhost") +settings.database.host = os.getenv("POSTGRES_HOST") or "localhost" # Uncomment to use a different port #settings.database.port = 3306 #settings.database.port = 5432 # Uncomment to select a different name for your database -settings.database.database = os.getenv("POSTGRES_DB", "sahana") +settings.database.database = os.getenv("POSTGRES_DB") or "sahana" # Uncomment to select a different username for your database -settings.database.username = os.getenv("POSTGRES_USER", "sahana") +settings.database.username = os.getenv("POSTGRES_USER") or "sahana" # Uncomment to set the password # NB Web2Py doesn't like passwords with an @ in them -settings.database.password = os.getenv("POSTGRES_PASSWORD", "password") +settings.database.password = os.getenv("POSTGRES_PASSWORD") or "password" # Uncomment to use a different pool size #settings.database.pool_size = 30 # Do we have a spatial DB available? (currently supports PostGIS. Spatialite to come.) @@ -52,7 +52,7 @@ settings.gis.spatialdb = True settings.base.system_name = T("Spotter Cluster") settings.base.system_name_short = T("Spotter") # Set this to the Public URL of the instance -settings.base.public_url = os.getenv("SAHANA_PUBLIC_URL", "http://127.0.0.1:8080") +settings.base.public_url = os.getenv("SAHANA_PUBLIC_URL") or "http://127.0.0.1:8080" # Switch to "False" in Production for a Performance gain # (need to set to "True" again when Table definitions are changed) @@ -87,7 +87,7 @@ settings.base.debug = True # This setting should be changed _before_ registering the 1st user # - should happen automatically if installing using supported scripts -settings.auth.hmac_key = os.getenv("SAHANA_HMAC_KEY", "akeytochange") +settings.auth.hmac_key = os.getenv("SAHANA_HMAC_KEY") or "akeytochange" # If using Masterkey Authentication, then set this to a deployment-specific 32 char string: #settings.auth.masterkey_app_key = "randomstringrandomstringrandomstring" @@ -97,18 +97,18 @@ settings.auth.hmac_key = os.getenv("SAHANA_HMAC_KEY", "akeytochange") # Email settings # Outbound server -settings.mail.server = os.getenv("SAHANA_MAIL_HOST", "127.0.0.1:25") +settings.mail.server = os.getenv("SAHANA_MAIL_HOST") or "127.0.0.1:25" #settings.mail.tls = True # Useful for Windows Laptops: # https://www.google.com/settings/security/lesssecureapps #settings.mail.server = "smtp.gmail.com:587" -#settings.mail.tls = True -#settings.mail.login = "username:password" +settings.mail.tls = True +settings.mail.login = os.getenv("SAHANA_MAIL_LOGIN") or False # From Address - until this is set, no mails can be sent -settings.mail.sender = os.getenv("SAHANA_MAIL_SENDER", "'Sahana' ") +settings.mail.sender = os.getenv("SAHANA_MAIL_SENDER") or "'Sahana' " # Default email address to which requests to approve new user accounts gets sent # This can be overridden for specific domains/organisations via the auth_domain table -settings.mail.approver = os.getenv("SAHANA_MAIL_APPROVER", "useradmin@example.org") +settings.mail.approver = os.getenv("SAHANA_MAIL_APPROVER") or "useradmin@example.org" # Daily Limit on Sending of emails #settings.mail.limit = 1000 @@ -121,9 +121,9 @@ settings.mail.approver = os.getenv("SAHANA_MAIL_APPROVER", "useradmin@example.or # GetAddress API Key (for GetAddress.io Postcode to Address lookup) #settings.gis.api_getaddress = "" # Google API Key (for Google Maps Layers) -settings.gis.api_google = os.getenv("SAHANA_API_KEY_GOOGLE", "") +settings.gis.api_google = os.getenv("SAHANA_API_KEY_GOOGLE") or "" # OpenWeatherMap API Key (for OpenWeatherMap Layers) -settings.gis.api_openweathermap = os.getenv("SAHANA_API_KEY_OPENWEATHERMAP", "") +settings.gis.api_openweathermap = os.getenv("SAHANA_API_KEY_OPENWEATHERMAP") or "" # GeoNames username #settings.gis.geonames_username = "" diff --git a/sahana/image.d/etc/sudoers.d/sahana b/sahana/image.d/etc/sudoers.d/sahana index 0a6389d..a04ee36 100644 --- a/sahana/image.d/etc/sudoers.d/sahana +++ b/sahana/image.d/etc/sudoers.d/sahana @@ -4,6 +4,7 @@ Defaults env_keep += "POSTGRES_DB" Defaults env_keep += "POSTGRES_HOST" Defaults env_keep += "SAHANA_HMAC_KEY" Defaults env_keep += "SAHANA_MAIL_HOST" +Defaults env_keep += "SAHANA_MAIL_LOGIN" Defaults env_keep += "SAHANA_MAIL_SENDER" Defaults env_keep += "SAHANA_MAIL_APPROVER" Defaults env_keep += "SAHANA_API_KEY_GOOGLE" diff --git a/sahana/image.d/srv/web2py/applications/eden/models/000_config.py b/sahana/image.d/srv/web2py/applications/eden/models/000_config.py index 108439e..ea7e57c 100644 --- a/sahana/image.d/srv/web2py/applications/eden/models/000_config.py +++ b/sahana/image.d/srv/web2py/applications/eden/models/000_config.py @@ -32,17 +32,17 @@ settings.base.template = "default" settings.database.db_type = "postgres" #settings.database.db_type = "mysql" # Uncomment to use a different host -settings.database.host = os.getenv("POSTGRES_HOST", "localhost") +settings.database.host = os.getenv("POSTGRES_HOST") or "localhost" # Uncomment to use a different port #settings.database.port = 3306 #settings.database.port = 5432 # Uncomment to select a different name for your database -settings.database.database = os.getenv("POSTGRES_DB", "sahana") +settings.database.database = os.getenv("POSTGRES_DB") or "sahana" # Uncomment to select a different username for your database -settings.database.username = os.getenv("POSTGRES_USER", "sahana") +settings.database.username = os.getenv("POSTGRES_USER") or "sahana" # Uncomment to set the password # NB Web2Py doesn't like passwords with an @ in them -settings.database.password = os.getenv("POSTGRES_PASSWORD", "password") +settings.database.password = os.getenv("POSTGRES_PASSWORD") or "password" # Uncomment to use a different pool size #settings.database.pool_size = 30 # Do we have a spatial DB available? (currently supports PostGIS. Spatialite to come.) @@ -52,7 +52,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 = os.getenv("SAHANA_PUBLIC_URL", "http://127.0.0.1:8080") +settings.base.public_url = os.getenv("SAHANA_PUBLIC_URL") or "http://127.0.0.1:8080" # Switch to "False" in Production for a Performance gain # (need to set to "True" again when Table definitions are changed) @@ -87,7 +87,7 @@ settings.base.debug = True # This setting should be changed _before_ registering the 1st user # - should happen automatically if installing using supported scripts -settings.auth.hmac_key = os.getenv("SAHANA_HMAC_KEY", "akeytochange") +settings.auth.hmac_key = os.getenv("SAHANA_HMAC_KEY") or "akeytochange" # If using Masterkey Authentication, then set this to a deployment-specific 32 char string: #settings.auth.masterkey_app_key = "randomstringrandomstringrandomstring" @@ -97,18 +97,18 @@ settings.auth.hmac_key = os.getenv("SAHANA_HMAC_KEY", "akeytochange") # Email settings # Outbound server -settings.mail.server = os.getenv("SAHANA_MAIL_HOST", "127.0.0.1:25") +settings.mail.server = os.getenv("SAHANA_MAIL_HOST") or "127.0.0.1:25" #settings.mail.tls = True # Useful for Windows Laptops: # https://www.google.com/settings/security/lesssecureapps #settings.mail.server = "smtp.gmail.com:587" -#settings.mail.tls = True -#settings.mail.login = "username:password" +settings.mail.tls = True +settings.mail.login = os.getenv("SAHANA_MAIL_LOGIN") or False # From Address - until this is set, no mails can be sent -settings.mail.sender = os.getenv("SAHANA_MAIL_SENDER", "'Sahana' ") +settings.mail.sender = os.getenv("SAHANA_MAIL_SENDER") or "'Sahana' " # Default email address to which requests to approve new user accounts gets sent # This can be overridden for specific domains/organisations via the auth_domain table -settings.mail.approver = os.getenv("SAHANA_MAIL_APPROVER", "useradmin@example.org") +settings.mail.approver = os.getenv("SAHANA_MAIL_APPROVER") or "useradmin@example.org" # Daily Limit on Sending of emails #settings.mail.limit = 1000 @@ -121,9 +121,9 @@ settings.mail.approver = os.getenv("SAHANA_MAIL_APPROVER", "useradmin@example.or # GetAddress API Key (for GetAddress.io Postcode to Address lookup) #settings.gis.api_getaddress = "" # Google API Key (for Google Maps Layers) -settings.gis.api_google = os.getenv("SAHANA_API_KEY_GOOGLE", "") +settings.gis.api_google = os.getenv("SAHANA_API_KEY_GOOGLE") or "" # OpenWeatherMap API Key (for OpenWeatherMap Layers) -settings.gis.api_openweathermap = os.getenv("SAHANA_API_KEY_OPENWEATHERMAP", "") +settings.gis.api_openweathermap = os.getenv("SAHANA_API_KEY_OPENWEATHERMAP") or "" # GeoNames username #settings.gis.geonames_username = ""