diff --git a/config/.env.sample b/config/.env.sample index 7e13e3a..2ddf458 100644 --- a/config/.env.sample +++ b/config/.env.sample @@ -7,8 +7,6 @@ DOMAIN_LE= # Let's Encrypt account email LE_EMAIL= - - # Skip the full planet download, useful for testing (true/false) SKIP_PLANET=false diff --git a/ssh_lib/__init__.py b/ssh_lib/__init__.py index 387fbe1..598a1f2 100644 --- a/ssh_lib/__init__.py +++ b/ssh_lib/__init__.py @@ -1,3 +1,5 @@ +import os +import sys from pathlib import Path from dotenv import dotenv_values @@ -19,7 +21,18 @@ PLANETILER_BIN = f'{TILE_GEN_DIR}/planetiler' HTTP_HOST_BIN = f'{OFM_DIR}/http_host/bin' -DOTENV_VALUES = dotenv_values(f'{CONFIG_DIR}/.env') + +ENV = os.getenv('ENV') +if ENV: + env_file_name = f'.env.{ENV}' +else: + env_file_name = '.env' + +env_file_path = CONFIG_DIR / env_file_name +if not env_file_path.exists(): + sys.exit(f'config/{env_file_name} does not exist') + +DOTENV_VALUES = dotenv_values(CONFIG_DIR / env_file_name) def dotenv_val(key): diff --git a/ssh_lib/tasks.py b/ssh_lib/tasks.py index 8e24b72..8101c2c 100644 --- a/ssh_lib/tasks.py +++ b/ssh_lib/tasks.py @@ -209,7 +209,7 @@ def upload_config_json(c): if not (domain_le or domain_ledns): sys.exit('Please specify DOMAIN_LE or DOMAIN_LEDNS in config/.env') - if domain_le and not le_email: + if domain_le and not le_email and not skip_letsencrypt: sys.exit('Please add your email to LE_EMAIL when using DOMAIN_LE') http_host_list = [h.strip() for h in dotenv_val('HTTP_HOST_LIST').split(',') if h.strip()] @@ -219,6 +219,7 @@ def upload_config_json(c): 'domain_ledns': domain_ledns, 'le_email': le_email, 'skip_planet': skip_planet, + 'skip_letsencrypt': skip_letsencrypt, 'http_host_list': http_host_list, 'telegram_token': dotenv_val('TELEGRAM_TOKEN'), 'telegram_chat_id': dotenv_val('TELEGRAM_CHAT_ID'),