From 9be759b8bb233c2da6d5a50ebc44f64918c76d8c Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Tue, 9 Oct 2018 19:33:17 +0200 Subject: T883: handle keyboard interrupts in the wireguard keypair command. --- src/op_mode/wireguard.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/op_mode/wireguard.py') diff --git a/src/op_mode/wireguard.py b/src/op_mode/wireguard.py index 14ee66aaf..73da72aa7 100755 --- a/src/op_mode/wireguard.py +++ b/src/op_mode/wireguard.py @@ -49,9 +49,12 @@ def genkey(): """ helper function to check, regenerate the keypair """ old_umask = os.umask(0o077) if os.path.exists(pk) and os.path.exists(pub): - choice = input("You already have a wireguard key-pair already, do you want to re-generate? [y/n] ") - if choice == 'y' or choice == 'Y': - generate_keypair() + try: + choice = input("You already have a wireguard key-pair already, do you want to re-generate? [y/n] ") + if choice == 'y' or choice == 'Y': + generate_keypair() + except KeyboardInterrupt: + sys.exit(0) else: if not os.path.exists(dir): os.mkdir(dir) -- cgit v1.2.3