From bc0a61b3c680ef64eabed7e606b10ab8c5897d21 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Mon, 8 Apr 2019 19:12:53 +0200 Subject: Added yubikey support, changed according to issues #6 and #7 --- archinstall.py | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/archinstall.py b/archinstall.py index 48d3a399..fd73824a 100644 --- a/archinstall.py +++ b/archinstall.py @@ -49,6 +49,9 @@ def get_local_MACs(): macs[addr.address] = nic return macs +def gen_yubikey_password(): + return None #TODO: Implement + def run(cmd, echo=False, opts=None, *args, **kwargs): if not opts: opts = {} if echo or 'debug' in opts: @@ -199,7 +202,8 @@ if __name__ == '__main__': if not 'packages' in args: args['packages'] = '' # extra packages other than default if not 'post' in args: args['post'] = 'reboot' if not 'password' in args: args['password'] = '0000' # Default disk passord, can be or a fixed string - if not 'no-default' in args: args['no-default'] = False + if not 'default' in args: args['default'] = False + if not 'profile' in args: args['profile'] = None if not 'profiles-path' in args: args['profiles-path'] = profiles_path ## == If we got networking, @@ -231,15 +235,24 @@ if __name__ == '__main__': else: print('[N] No gateway - No net deploy') - first = True - while args['no-default'] and len(instructions) <= 0: - profile = input('What template do you want to install: ') - instructions = get_instructions(profile) - if first and len(instructions) <= 0: - print('[E] No instructions by the name of {} was found.'.format(profile)) + if args['profile'] and not args['default']: + instructions = get_instructions(args['profile']) + if len(instructions) <= 0: + print('[E] No instructions by the name of {} was found.'.format(args['profile'])) print(' Installation won\'t continue until a valid profile is given.') - print(' (this is because --no-default was given and a default installation is prohibited)') - first = False + print(' (this is because --profile was given and a --default is not given)') + exit(1) + else: + first = True + while not args['default'] and not args['profile'] and len(instructions) <= 0: + profile = input('What template do you want to install: ') + instructions = get_instructions(profile) + if first and len(instructions) <= 0: + print('[E] No instructions by the name of {} was found.'.format(profile)) + print(' Installation won\'t continue until a valid profile is given.') + print(' (this is because --default is not instructed and no --profile given)') + first = False + if 'args' in instructions: ## == Recursively fetch instructions if "include" is found under {args: ...} @@ -264,6 +277,12 @@ if __name__ == '__main__': args[key] = val if args['password'] == '': args['password'] = input('Enter a disk (and root) password: ') + elif args['password'] == '': + args['password'] = gen_yubikey_password() + if not args['password']: + print('[E] Failed to setup a yubikey password, is it plugged in?') + exit(1) + print(args) if not os.path.isfile(args['pwfile']): -- cgit v1.2.3-70-g09d2 From 9c572a3204bdced31b1fb4622617ba9134382467 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Mon, 8 Apr 2019 20:29:49 +0200 Subject: Verified implementation for #6 and #7 --- archinstall.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/archinstall.py b/archinstall.py index fd73824a..c7d6062b 100644 --- a/archinstall.py +++ b/archinstall.py @@ -23,7 +23,7 @@ positionals = [] for arg in sys.argv[1:]: if '--' == arg[:2]: if '=' in arg: - key, val = [strip(x) for x in arg[2:].split('=')] + key, val = [x.strip() for x in arg[2:].split('=')] else: key, val = arg[2:], True args[key] = val -- cgit v1.2.3-70-g09d2