From 627daefa25d9be7a6829ebf182e9ea8b04929fae Mon Sep 17 00:00:00 2001 From: Emilien Devos <4016501+unixfox@users.noreply.github.com> Date: Mon, 6 Nov 2023 22:00:08 +0100 Subject: [PATCH] fixing argsparse in the wrong section --- smart-ipv6-rotator.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/smart-ipv6-rotator.py b/smart-ipv6-rotator.py index bca57a2..31f7c52 100644 --- a/smart-ipv6-rotator.py +++ b/smart-ipv6-rotator.py @@ -74,16 +74,7 @@ def check_ipv6_connectivity(self): print("[INFO] You have IPv6 connectivity. Continuing.") - def clean_previous_setup(self, existing_settings): - parser = argparse.ArgumentParser(description="Run the IPv6 rotator.") - parser.add_argument( - "--skip-root", - required=False, - dest='skip_root_check', - action=argparse.BooleanOptionalAction, - help="Example: --skip-root for skipping root check", - ) - args = parser.parse_args(sys.argv[2:]) + def clean_previous_setup(self, existing_settings, args): if os.geteuid() != 0 and not args.skip_root_check: sys.exit( @@ -151,8 +142,15 @@ def clean_previous_setup(self, existing_settings): def clean(self): parser = argparse.ArgumentParser(description="Clean the previous setup.") + parser.add_argument( + "--skip-root", + required=False, + dest='skip_root_check', + action=argparse.BooleanOptionalAction, + help="Example: --skip-root for skipping root check", + ) args = parser.parse_args(sys.argv[2:]) - self.clean_previous_setup({}) + self.clean_previous_setup({}, args) def run(self): parser = argparse.ArgumentParser(description="Run the IPv6 rotator.") @@ -177,7 +175,7 @@ def run(self): ) self.check_ipv6_connectivity() - self.clean_previous_setup({}) + self.clean_previous_setup({}, args) # calculate random IPv6 from the configured subnet