diff --git a/modules/http_host/http_host_lib/nginx.py b/modules/http_host/http_host_lib/nginx.py index e2c2a1c..cf27f1e 100644 --- a/modules/http_host/http_host_lib/nginx.py +++ b/modules/http_host/http_host_lib/nginx.py @@ -17,6 +17,7 @@ def write_nginx_config(): domain_le = config.ofm_config['domain_le'] domain_ledns = config.ofm_config['domain_ledns'] + skip_letsencrypt = config.ofm_config['skip_letsencrypt'] # remove old configs and certs for file in Path('/data/nginx/sites').glob('ofm_*.conf'): @@ -58,36 +59,37 @@ def write_nginx_config(): subprocess.run(['nginx', '-t'], check=True) subprocess.run(['systemctl', 'reload', 'nginx'], check=True) - subprocess.run( - [ - 'certbot', - 'certonly', - '--webroot', - '--webroot-path=/data/nginx/acme-challenges', - '--noninteractive', - '-m', - config.ofm_config['le_email'], - '--agree-tos', - '--cert-name=ofm_le', - # '--staging', - '--deploy-hook', - 'nginx -t && service nginx reload', - '-d', - domain_le, - ], - check=True, - ) + if not skip_letsencrypt: + subprocess.run( + [ + 'certbot', + 'certonly', + '--webroot', + '--webroot-path=/data/nginx/acme-challenges', + '--noninteractive', + '-m', + config.ofm_config['le_email'], + '--agree-tos', + '--cert-name=ofm_le', + # '--staging', + '--deploy-hook', + 'nginx -t && service nginx reload', + '-d', + domain_le, + ], + check=True, + ) - # link certs to nginx dir - le_cert.unlink() - le_key.unlink() + # link certs to nginx dir + le_cert.unlink() + le_key.unlink() - etc_cert = Path('/etc/letsencrypt/live/ofm_le/fullchain.pem') - etc_key = Path('/etc/letsencrypt/live/ofm_le/privkey.pem') - assert etc_cert.is_file() - assert etc_key.is_file() - le_cert.symlink_to(etc_cert) - le_key.symlink_to(etc_key) + etc_cert = Path('/etc/letsencrypt/live/ofm_le/fullchain.pem') + etc_key = Path('/etc/letsencrypt/live/ofm_le/privkey.pem') + assert etc_cert.is_file() + assert etc_key.is_file() + le_cert.symlink_to(etc_cert) + le_key.symlink_to(etc_key) subprocess.run(['nginx', '-t'], check=True) subprocess.run(['systemctl', 'reload', 'nginx'], check=True) diff --git a/ssh_lib/__init__.py b/ssh_lib/__init__.py index 598a1f2..668f1b2 100644 --- a/ssh_lib/__init__.py +++ b/ssh_lib/__init__.py @@ -22,6 +22,9 @@ PLANETILER_BIN = f'{TILE_GEN_DIR}/planetiler' HTTP_HOST_BIN = f'{OFM_DIR}/http_host/bin' +# Handling multiple .env files is supported +# or example ENV=test would use .env.test + ENV = os.getenv('ENV') if ENV: env_file_name = f'.env.{ENV}'