commit
7cf9b8d138
|
|
@ -23,7 +23,7 @@ positionals = []
|
||||||
for arg in sys.argv[1:]:
|
for arg in sys.argv[1:]:
|
||||||
if '--' == arg[:2]:
|
if '--' == arg[:2]:
|
||||||
if '=' in arg:
|
if '=' in arg:
|
||||||
key, val = [strip(x) for x in arg[2:].split('=')]
|
key, val = [x.strip() for x in arg[2:].split('=')]
|
||||||
else:
|
else:
|
||||||
key, val = arg[2:], True
|
key, val = arg[2:], True
|
||||||
args[key] = val
|
args[key] = val
|
||||||
|
|
@ -49,6 +49,9 @@ def get_local_MACs():
|
||||||
macs[addr.address] = nic
|
macs[addr.address] = nic
|
||||||
return macs
|
return macs
|
||||||
|
|
||||||
|
def gen_yubikey_password():
|
||||||
|
return None #TODO: Implement
|
||||||
|
|
||||||
def run(cmd, echo=False, opts=None, *args, **kwargs):
|
def run(cmd, echo=False, opts=None, *args, **kwargs):
|
||||||
if not opts: opts = {}
|
if not opts: opts = {}
|
||||||
if echo or 'debug' in 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 'packages' in args: args['packages'] = '' # extra packages other than default
|
||||||
if not 'post' in args: args['post'] = 'reboot'
|
if not 'post' in args: args['post'] = 'reboot'
|
||||||
if not 'password' in args: args['password'] = '0000' # Default disk passord, can be <STDIN> or a fixed string
|
if not 'password' in args: args['password'] = '0000' # Default disk passord, can be <STDIN> 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 not 'profiles-path' in args: args['profiles-path'] = profiles_path
|
||||||
|
|
||||||
## == If we got networking,
|
## == If we got networking,
|
||||||
|
|
@ -231,15 +235,24 @@ if __name__ == '__main__':
|
||||||
else:
|
else:
|
||||||
print('[N] No gateway - No net deploy')
|
print('[N] No gateway - No net deploy')
|
||||||
|
|
||||||
first = True
|
if args['profile'] and not args['default']:
|
||||||
while args['no-default'] and len(instructions) <= 0:
|
instructions = get_instructions(args['profile'])
|
||||||
profile = input('What template do you want to install: ')
|
if len(instructions) <= 0:
|
||||||
instructions = get_instructions(profile)
|
print('[E] No instructions by the name of {} was found.'.format(args['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(' Installation won\'t continue until a valid profile is given.')
|
||||||
print(' (this is because --no-default was given and a default installation is prohibited)')
|
print(' (this is because --profile was given and a --default is not given)')
|
||||||
first = False
|
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:
|
if 'args' in instructions:
|
||||||
## == Recursively fetch instructions if "include" is found under {args: ...}
|
## == Recursively fetch instructions if "include" is found under {args: ...}
|
||||||
|
|
@ -264,6 +277,12 @@ if __name__ == '__main__':
|
||||||
args[key] = val
|
args[key] = val
|
||||||
|
|
||||||
if args['password'] == '<STDIN>': args['password'] = input('Enter a disk (and root) password: ')
|
if args['password'] == '<STDIN>': args['password'] = input('Enter a disk (and root) password: ')
|
||||||
|
elif args['password'] == '<YUBIKEY>':
|
||||||
|
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)
|
print(args)
|
||||||
|
|
||||||
if not os.path.isfile(args['pwfile']):
|
if not os.path.isfile(args['pwfile']):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue