From f5a7b0025695c11b0bf9d4815f012708753ce23d Mon Sep 17 00:00:00 2001 From: Zsolt Ero Date: Thu, 12 Sep 2024 11:44:23 +0200 Subject: [PATCH] add noninteractive option --- .gitignore | 1 + init-server.py | 25 +++++++++++++----------- modules/http_host/http_host_lib/mount.py | 2 +- modules/tile_gen/cron.d/ofm_tile_gen | 5 ++++- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 6a6804a..313e965 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,4 @@ venv /pnpm-lock.yaml +/deploy-all.sh diff --git a/init-server.py b/init-server.py index 0ff8fa4..947913e 100755 --- a/init-server.py +++ b/init-server.py @@ -46,6 +46,9 @@ def common_options(func): func = click.argument('hostname')(func) func = click.option('--port', type=int, help='SSH port (if not in .ssh/config)')(func) func = click.option('--user', help='SSH user (if not in .ssh/config)')(func) + func = click.option('-y', '--noninteractive', is_flag=True, help='Skip confirmation questions')( + func + ) return func @@ -56,8 +59,8 @@ def cli(): @cli.command() @common_options -def http_host_static(hostname, user, port): - if not click.confirm(f'Run script on {hostname}?'): +def http_host_static(hostname, user, port, noninteractive): + if not noninteractive and click.confirm(f'Run script on {hostname}?'): return c = get_connection(hostname, user, port) @@ -72,8 +75,8 @@ def http_host_static(hostname, user, port): @cli.command() @common_options -def http_host_autoupdate(hostname, user, port): - if not click.confirm(f'Run script on {hostname}?'): +def http_host_autoupdate(hostname, user, port, noninteractive): + if not noninteractive and click.confirm(f'Run script on {hostname}?'): return c = get_connection(hostname, user, port) @@ -93,8 +96,8 @@ def http_host_autoupdate(hostname, user, port): @cli.command() @common_options @click.option('--cron', is_flag=True, help='Enable cron task') -def tile_gen(hostname, user, port, cron): - if not click.confirm(f'Run script on {hostname}?'): +def tile_gen(hostname, user, port, cron, noninteractive): + if not noninteractive and click.confirm(f'Run script on {hostname}?'): return c = get_connection(hostname, user, port) @@ -105,8 +108,8 @@ def tile_gen(hostname, user, port, cron): @cli.command() @common_options -def ledns(hostname, user, port): - if not click.confirm(f'Run script on {hostname}?'): +def ledns(hostname, user, port, noninteractive): + if not noninteractive and click.confirm(f'Run script on {hostname}?'): return c = get_connection(hostname, user, port) @@ -116,8 +119,8 @@ def ledns(hostname, user, port): @cli.command() @common_options -def loadbalancer(hostname, user, port): - if not click.confirm(f'Run script on {hostname}?'): +def loadbalancer(hostname, user, port, noninteractive): + if not noninteractive and click.confirm(f'Run script on {hostname}?'): return c = get_connection(hostname, user, port) @@ -128,7 +131,7 @@ def loadbalancer(hostname, user, port): @cli.command() @common_options -def debug(hostname, user, port): +def debug(hostname, user, port, noninteractive): c = get_connection(hostname, user, port) upload_config_json(c) diff --git a/modules/http_host/http_host_lib/mount.py b/modules/http_host/http_host_lib/mount.py index 9683c1f..6358b46 100644 --- a/modules/http_host/http_host_lib/mount.py +++ b/modules/http_host/http_host_lib/mount.py @@ -20,7 +20,7 @@ def auto_mount(): if not config.runs_dir.exists(): sys.exit(' download-btrfs needs to be run first') - clean_up_mounts(config.mnt_dir) + # clean_up_mounts(config.mnt_dir) # disabling, as it can be in use before the nginx sync works create_fstab() print(' running mount -a') diff --git a/modules/tile_gen/cron.d/ofm_tile_gen b/modules/tile_gen/cron.d/ofm_tile_gen index a3c0c1b..d7a34ae 100644 --- a/modules/tile_gen/cron.d/ofm_tile_gen +++ b/modules/tile_gen/cron.d/ofm_tile_gen @@ -3,7 +3,10 @@ CMD="sudo /data/ofm/venv/bin/python -u /data/ofm/tile_gen/bin/tile_gen.py" LOG_DIR=/data/ofm/tile_gen/logs # every day at 2:10, make a monaco run -10 2 * * * ofm $CMD make-tiles monaco --upload >> $LOG_DIR/monaco-make-tiles.log 2>&1 +#10 2 * * * ofm $CMD make-tiles monaco --upload >> $LOG_DIR/monaco-make-tiles.log 2>&1 + +# debug every 15 minutes +*/15 * * * * ofm $CMD make-tiles monaco --upload >> $LOG_DIR/monaco-make-tiles.log 2>&1 # every minute, set monaco to latest * * * * * ofm $CMD set-version monaco >> $LOG_DIR/monaco-set-version.log 2>&1