From 8594d730c7f2c60bbd2860ed711ddb70790ebada Mon Sep 17 00:00:00 2001 From: Zsolt Ero Date: Wed, 8 Oct 2025 01:47:35 +0200 Subject: [PATCH] work --- init-server.py | 10 +++++----- modules/http_host/http_host_lib/config.py | 2 -- ssh_lib/nginx.py | 3 +++ ssh_lib/tasks_http_host.py | 16 +++++++++++----- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/init-server.py b/init-server.py index f6feef0..963f9c2 100755 --- a/init-server.py +++ b/init-server.py @@ -4,7 +4,7 @@ import click from fabric import Config, Connection from ssh_lib.config import config -from ssh_lib.tasks_http_host import prepare_http_host, run_http_host_sync +from ssh_lib.tasks_http_host import prepare_http_host, run_http_host_sync, upload_config_and_certs from ssh_lib.tasks_shared import prepare_shared from ssh_lib.tasks_tile_gen import prepare_tile_gen from ssh_lib.utils import ( @@ -78,10 +78,10 @@ def http_host_autoupdate(hostname, user, port, noninteractive): # prepare_shared(c) prepare_http_host(c) - # - # run_http_host_sync(c) # disable for first install if you don't want to wait - # - # put(c, config.local_modules_dir / 'http_host' / 'cron.d' / 'ofm_http_host', '/etc/cron.d/') + + run_http_host_sync(c) # disable for first install if you don't want to wait + + put(c, config.local_modules_dir / 'http_host' / 'cron.d' / 'ofm_http_host', '/etc/cron.d/') @cli.command() diff --git a/modules/http_host/http_host_lib/config.py b/modules/http_host/http_host_lib/config.py index bc901b9..f7b3cdc 100644 --- a/modules/http_host/http_host_lib/config.py +++ b/modules/http_host/http_host_lib/config.py @@ -2,8 +2,6 @@ import json import subprocess from pathlib import Path -import json5 - class Configuration: areas = ['planet', 'monaco'] diff --git a/ssh_lib/nginx.py b/ssh_lib/nginx.py index 602745c..b817224 100644 --- a/ssh_lib/nginx.py +++ b/ssh_lib/nginx.py @@ -53,6 +53,9 @@ def nginx(c): def certbot(c): + print('should use nginx acme') + return + apt_get_install(c, 'snapd') # this is silly, but needs to be run twice diff --git a/ssh_lib/tasks_http_host.py b/ssh_lib/tasks_http_host.py index 1383c3a..7aafb87 100644 --- a/ssh_lib/tasks_http_host.py +++ b/ssh_lib/tasks_http_host.py @@ -17,7 +17,7 @@ def prepare_http_host(c): kernel_limits1m(c) nginx(c) - certbot(c) + # certbot(c) c.sudo(f'rm -rf {config.http_host_dir}/logs') c.sudo(f'mkdir -p {config.http_host_dir}/logs') @@ -72,11 +72,17 @@ def upload_config_and_certs(c): if domain_data['cert']['type'] == 'upload': local_cert_path = Path(domain_data['cert']['cert_path']) + + # handle relative paths - make them relative to config.local_config_dir + if not local_cert_path.is_absolute(): + local_cert_path = Path(config.local_config_dir) / local_cert_path + cert_basename = local_cert_path.stem local_key_path = local_cert_path.parent / f'{cert_basename}.key' - if not local_cert_path.is_file() or local_key_path.is_file(): + + if not local_cert_path.is_file() or not local_key_path.is_file(): print( - f'cert or key file for {domain_data["domain"]} is not found. Make sure these files exists: {local_cert_path} {local_key_path}' + f'cert or key file for {domain_data["domain"]} is not found.\nMake sure these files exists:\n{local_cert_path}\n{local_key_path}\n------' ) remote_cert_path = f'/data/nginx/certs/ofm-{domain_data["slug"]}.cert' @@ -103,8 +109,8 @@ def upload_http_host_files(c): put_dir( c, - config.local_modules_dir / 'http_host' / 'http_host_lib' / 'nginx_confs', - f'{config.http_host_bin}/http_host_lib/nginx_confs', + config.local_modules_dir / 'http_host' / 'http_host_lib' / 'nginx_templates', + f'{config.http_host_bin}/http_host_lib/nginx_templates', ) c.sudo('chown -R ofm:ofm /data/ofm/http_host')