From b5aa645850fc82293a0d510c4b088d28769e2c78 Mon Sep 17 00:00:00 2001 From: Daan Selen Date: Fri, 10 Jan 2025 10:56:03 +0100 Subject: [PATCH] Added an optional grace-period to the execution of the script. This is done to prevent accidentaly wrong launches. If its not needed then disable it through `--nograce` (no grace (period)) --- meshbook.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/meshbook.py b/meshbook.py index c190041..9c9a54f 100644 --- a/meshbook.py +++ b/meshbook.py @@ -142,7 +142,7 @@ async def main(): parser = argparse.ArgumentParser(description="Process command-line arguments") parser.add_argument("-pb", "--playbook", type=str, help="Path to the playbook file.", required=True) parser.add_argument("--conf", type=str, help="Path for the API configuration file (default: ./api.conf).", required=False) - parser.add_argument("--noout", action="store_true", help="Makes the program not output response data.", required=False) + parser.add_argument("--nograce", action="store_true", help="Disable the grace 3 seconds before running the playbook.", required=False) parser.add_argument("-s", "--silent", action="store_true", help="Suppress terminal output", required=False) global args @@ -166,11 +166,15 @@ async def main(): group_list = await compile_group_list(session) targets_list = await gather_targets(playbook) - output_text(("-" * 40), False) if len(targets_list) == 0: output_text(("\033[91mNo targets found or targets unreachable, quitting.\x1B[0m"), True) else: - output_text(("\033[91mExecuting playbook on the targets.\x1B[0m"), False) + output_text(("-" * 40), False) + target_name = playbook["group"] if "group" in playbook else playbook["device"] # Quickly get the name. + output_text(("\033[91mExecuting playbook on the targets: " + target_name + ".\x1B[0m"), False) + if not args.nograce: + output_text(("\033[91mInitiating grace-period...\x1B[0m"), False) + await asyncio.sleep(3) await execute_playbook(session, targets_list, playbook) await session.close()