From e079bd1c67561cb9ce4ad32bdaa8063e35beab28 Mon Sep 17 00:00:00 2001 From: Zsolt Ero Date: Sun, 3 Mar 2024 01:03:50 +0100 Subject: [PATCH] ledns --- config/rclone.conf.sample | 2 +- init-server.py | 7 ++++--- scripts/tile_gen/cloudflare_index.sh | 6 +++--- scripts/tile_gen/cloudflare_upload.sh | 2 +- ssh_lib/tasks.py | 19 ++++++++++++++++--- 5 files changed, 25 insertions(+), 11 deletions(-) diff --git a/config/rclone.conf.sample b/config/rclone.conf.sample index a87ee7e..0c394bd 100644 --- a/config/rclone.conf.sample +++ b/config/rclone.conf.sample @@ -1,4 +1,4 @@ -[cf] +[remote] type = s3 provider = Cloudflare access_key_id = xxx diff --git a/init-server.py b/init-server.py index d9e1125..c313ae7 100755 --- a/init-server.py +++ b/init-server.py @@ -10,7 +10,7 @@ from ssh_lib.tasks import ( prepare_shared, prepare_tile_gen, run_http_host_sync, - setup_ledns_manager, + setup_ledns_writer, upload_http_host_config, ) from ssh_lib.utils import ( @@ -98,13 +98,14 @@ def tile_gen(hostname, user, port): @cli.command() @common_options -def ledns_manager(hostname, user, port): +def ledns_writer(hostname, user, port): if not click.confirm(f'Run script on {hostname}?'): return c = get_connection(hostname, user, port) - setup_ledns_manager(c) + setup_ledns_writer(c) + @cli.command() diff --git a/scripts/tile_gen/cloudflare_index.sh b/scripts/tile_gen/cloudflare_index.sh index 72e7780..80e5f9b 100755 --- a/scripts/tile_gen/cloudflare_index.sh +++ b/scripts/tile_gen/cloudflare_index.sh @@ -14,15 +14,15 @@ for AREA in "${AREAS[@]}"; do --fast-list \ --exclude dirs.txt \ --exclude index.txt \ - "cf:ofm-$AREA" > index/index.txt + "remote:ofm-$AREA" > index/index.txt rclone lsf -R \ --dirs-only \ --dir-slash=false \ --fast-list \ - "cf:ofm-$AREA" > index/dirs.txt + "remote:ofm-$AREA" > index/dirs.txt - rclone copy index "cf:ofm-$AREA" + rclone copy index "remote:ofm-$AREA" done rm -rf index diff --git a/scripts/tile_gen/cloudflare_upload.sh b/scripts/tile_gen/cloudflare_upload.sh index ac44105..7826c15 100755 --- a/scripts/tile_gen/cloudflare_upload.sh +++ b/scripts/tile_gen/cloudflare_upload.sh @@ -30,7 +30,7 @@ rclone sync \ --stats-one-line \ --log-file logs/rclone.log \ --exclude 'logs/**' \ - . "cf:ofm-$AREA/$VERSION" + . "remote:ofm-$AREA/$VERSION" bash "$SCRIPT_DIR/cloudflare_index.sh" \ No newline at end of file diff --git a/ssh_lib/tasks.py b/ssh_lib/tasks.py index d3f24bd..a14c554 100644 --- a/ssh_lib/tasks.py +++ b/ssh_lib/tasks.py @@ -30,8 +30,8 @@ def prepare_shared(c): kernel_tweaks_ofm(c) c.sudo(f'mkdir -p {REMOTE_CONFIG}') - c.sudo('chown ofm:ofm /data/ofm/config') - c.sudo('chown ofm:ofm /data/ofm') + c.sudo(f'chown ofm:ofm {REMOTE_CONFIG}') + c.sudo(f'chown ofm:ofm {OFM_DIR}') prepare_venv(c) @@ -178,11 +178,24 @@ def install_benchmark(c): wrk(c) -def setup_ledns_manager(c): +def setup_ledns_writer(c): le_email = dotenv_val('LE_EMAIL').lower() domain_ledns = dotenv_val('DOMAIN_LEDNS').lower() assert le_email assert domain_ledns + assert (CONFIG_DIR / 'rclone.conf').exists() + + rclone(c) + c.sudo(f'mkdir -p {REMOTE_CONFIG}') + + put( + c, + CONFIG_DIR / 'rclone.conf', + f'{REMOTE_CONFIG}/rclone.conf', + permissions='600', + ) + + return c.sudo('mkdir -p /root/.secrets')