Skip to content

Commit

Permalink
fixing argsparse in the wrong section
Browse files Browse the repository at this point in the history
  • Loading branch information
unixfox committed Nov 6, 2023
1 parent 66debf1 commit 627daef
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions smart-ipv6-rotator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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.")
Expand All @@ -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

Expand Down

0 comments on commit 627daef

Please sign in to comment.