Finalizing working net deploy

This commit is contained in:
Lord Anton Hvornum 2018-04-07 23:15:32 +02:00
parent 13a1c2ab3a
commit 82fe158552
1 changed files with 10 additions and 12 deletions

View File

@ -218,11 +218,9 @@ if __name__ == '__main__':
o = run('arch-chroot /mnt chmod 700 /root')
## == Passwords
#o = run('arch-chroot /mnt usermod --password {} root'.format(PIN))
#TODO: This doesn't work either: (why the hell not?)
# echo "newpass" | passwd --stdin root ?
#o = run("arch-chroot /mnt echo 'root:{pin}' | chpasswd".format(**args, pin=PIN))
o = run("arch-chroot /mnt sh -c 'echo {pin} | passwd --stdin root'".format(pin='"{pin}"'.format(**args, pin=PIN)), echo=True)
# o = run('arch-chroot /mnt usermod --password {} root'.format(PIN))
# o = run("arch-chroot /mnt sh -c 'echo {pin} | passwd --stdin root'".format(pin='"{pin}"'.format(**args, pin=PIN)), echo=True)
o = run("arch-chroot /mnt sh -c \"echo 'root:{pin}' | chpasswd\"".format(**args, pin=PIN))
if 'user' in args:
o = run('arch-chroot /mnt useradd -m -G wheel {user}'.format(**args))
o = run("arch-chroot /mnt echo '{user}:{pin}' | chpasswd".format(**args, pin=PIN))
@ -265,18 +263,18 @@ if __name__ == '__main__':
instructions = json.loads(instructions.decode('UTF-8'), object_pairs_hook=oDict)
for title in instructions:
print('[N] {}'.format(title))
print('[N] Network Deploy: {}'.format(title))
for command in instructions[title]:
opts = instructions[title][command] if type(instructions[title][command]) in (dict, oDict) else {}
print('[N] Command: {} ({})'.format(command, opts))
#print('[N] Command: {} ({})'.format(command, opts))
o = run('arch-chroot /mnt {c}'.format(c=command), **opts)
if type(instructions[title][command]) == bytes and len(instructions[title][command]) and not instructions[title][command] in o:
print('[W] Post install command failed: {}'.format(o.decode('UTF-8')))
#print(o)
#o = run('umount -R /mnt')
#if args['post'] == 'reboot':
# o = run('reboot now')
#else:
# print('Done. "reboot" when you\'re done tinkering.')
o = run('umount -R /mnt')
if args['post'] == 'reboot':
o = run('reboot now')
else:
print('Done. "reboot" when you\'re done tinkering.')