From 828cca1beb78d86a6d646b24aed9d412b8b2b890 Mon Sep 17 00:00:00 2001 From: Lord Anton Hvornum Date: Sat, 7 Apr 2018 09:51:38 +0200 Subject: Added support for remote HTTPS instructions --- archinstall.py | 56 +++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 49 insertions(+), 7 deletions(-) (limited to 'archinstall.py') diff --git a/archinstall.py b/archinstall.py index a9721e17..1d3672a0 100644 --- a/archinstall.py +++ b/archinstall.py @@ -1,7 +1,9 @@ #!/usr/bin/python3 -import psutil, os, re, struct, sys +import psutil, os, re, struct, sys, json +import urllib.request, urllib.parse from glob import glob -from socket import inet_ntoa, AF_INET, AF_INET6 +#from select import epoll, EPOLLIN, EPOLLHUP +from socket import socket, inet_ntoa, AF_INET, AF_INET6, AF_PACKET from collections import OrderedDict as oDict from subprocess import Popen, STDOUT, PIPE @@ -30,11 +32,14 @@ def get_default_gateway_linux(): return inet_ntoa(struct.pack(" Date: Sat, 7 Apr 2018 10:05:30 +0200 Subject: Modified the install command and debug output --- archinstall.py | 46 +++++++++++++++++++++----------------- deployments/9c:d6:43:ae:11:4f.json | 2 +- 2 files changed, 26 insertions(+), 22 deletions(-) (limited to 'archinstall.py') diff --git a/archinstall.py b/archinstall.py index 1d3672a0..f078445f 100644 --- a/archinstall.py +++ b/archinstall.py @@ -213,7 +213,8 @@ if __name__ == '__main__': #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 echo 'root:{pin}' | chpasswd".format(**args, pin=PIN)) + o = run('arch-chroot /mnt echo "{pin}" | passwd --stdin root'.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)) @@ -241,25 +242,28 @@ if __name__ == '__main__': entry.write('initrd /initramfs-linux.img\n') entry.write('options cryptdevice=UUID={UUID}:luksdev root=/dev/mapper/luksdev rw intel_pstate=no_hwp\n'.format(UUID=UUID)) - locmac = get_local_MACs() - for mac in locmac: - try: - instructions = grab_url_data('https://raw.githubusercontent.com/Torxed/archinstall/net-deploy/deployments/{}.json'.format(mac)) - except urllib.error.HTTPError: - print('[N] No instructions for this box on this mac: {}'.format(mac)) - continue - - instructions = json.loads(instructions.decode('UTF-8')) - - for title in instructions: - print('[N] {}'.format(title)) - for command in instructions[title]: - o = run(command) # arch-chroot /mnt ... - if instructions[title][command]: + ## == If we got networking, + # Try fetching instructions for this box and execute them. + if get_default_gateway_linux(): + locmac = get_local_MACs() + for mac in locmac: + try: + instructions = grab_url_data('https://raw.githubusercontent.com/Torxed/archinstall/net-deploy/deployments/{}.json'.format(mac)) + except urllib.error.HTTPError: + print('[N] No instructions for this box on this mac: {}'.format(mac)) + continue + + instructions = json.loads(instructions.decode('UTF-8')) + + for title in instructions: + print('[N] {}'.format(title)) + for command in instructions[title]: + o = run(command) # arch-chroot /mnt ... + #if instructions[title][command]: 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.') diff --git a/deployments/9c:d6:43:ae:11:4f.json b/deployments/9c:d6:43:ae:11:4f.json index 6b4bd69e..ab988e44 100644 --- a/deployments/9c:d6:43:ae:11:4f.json +++ b/deployments/9c:d6:43:ae:11:4f.json @@ -1,5 +1,5 @@ { "install ssh": { - "pacman -y -S cmatrix" : null + "pacman -Syy --noconfirm cmatrix" : null } } -- cgit v1.2.3-70-g09d2 From 20ba0b145cdccf5bf98879ca9e1a6811ef078519 Mon Sep 17 00:00:00 2001 From: Lord Anton Hvornum Date: Sat, 7 Apr 2018 10:48:23 +0200 Subject: Forgot to execute post-install inside arch-chroot --- archinstall.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'archinstall.py') diff --git a/archinstall.py b/archinstall.py index f078445f..5970b385 100644 --- a/archinstall.py +++ b/archinstall.py @@ -214,7 +214,7 @@ if __name__ == '__main__': #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 echo "{pin}" | passwd --stdin root'.format(**args, pin=PIN)) + o = run('arch-chroot /mnt \'echo "{pin}" | passwd --stdin root\''.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)) @@ -258,9 +258,10 @@ if __name__ == '__main__': for title in instructions: print('[N] {}'.format(title)) for command in instructions[title]: - o = run(command) # arch-chroot /mnt ... - #if instructions[title][command]: - print(o) + o = run('arch-chroot /mnt {c}'.format(c=command)) + if 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': -- cgit v1.2.3-70-g09d2 From 9869d8d27db7ae6c13f5ed426d6263da3cf6fb7b Mon Sep 17 00:00:00 2001 From: Lord Anton Hvornum Date: Sat, 7 Apr 2018 13:21:23 +0200 Subject: Made sure commands are executed in order --- archinstall.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'archinstall.py') diff --git a/archinstall.py b/archinstall.py index 5970b385..d8de16b1 100644 --- a/archinstall.py +++ b/archinstall.py @@ -253,7 +253,8 @@ if __name__ == '__main__': print('[N] No instructions for this box on this mac: {}'.format(mac)) continue - instructions = json.loads(instructions.decode('UTF-8')) + print('Decoding:', instructions) + instructions = json.loads(instructions.decode('UTF-8'), object_pairs_hook=oDict) for title in instructions: print('[N] {}'.format(title)) -- cgit v1.2.3-70-g09d2 From 17c810d897505949b547a3c0ed555cedf9b4acdf Mon Sep 17 00:00:00 2001 From: Lord Anton Hvornum Date: Sat, 7 Apr 2018 14:09:25 +0200 Subject: more debug --- archinstall.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'archinstall.py') diff --git a/archinstall.py b/archinstall.py index d8de16b1..2e1f30c6 100644 --- a/archinstall.py +++ b/archinstall.py @@ -41,13 +41,15 @@ def get_local_MACs(): macs[addr.address] = nic return macs -def run(cmd): +def run(cmd, echo=False): #print('[!] {}'.format(cmd)) handle = Popen(cmd, shell='True', stdout=PIPE, stderr=STDOUT) output = b'' while handle.poll() is None: data = handle.stdout.read() if len(data): + if echo: + print(data.decode('UTF-8', end='')) # print(data.decode('UTF-8'), end='') output += data output += handle.stdout.read() @@ -253,13 +255,14 @@ if __name__ == '__main__': print('[N] No instructions for this box on this mac: {}'.format(mac)) continue - print('Decoding:', instructions) + #print('Decoding:', instructions) instructions = json.loads(instructions.decode('UTF-8'), object_pairs_hook=oDict) for title in instructions: print('[N] {}'.format(title)) for command in instructions[title]: - o = run('arch-chroot /mnt {c}'.format(c=command)) + print('[N] Command: {}'.format(command)) + o = run('arch-chroot /mnt {c}'.format(c=command), echo=True) if instructions[title][command] and not instructions[title][command] in o: print('[W] Post install command failed: {}'.format(o.decode('UTF-8'))) #print(o) -- cgit v1.2.3-70-g09d2 From 14ee4cdf8ced0fc76cf92a0f2f4cbf11c1824266 Mon Sep 17 00:00:00 2001 From: Lord Anton Hvornum Date: Sat, 7 Apr 2018 14:23:08 +0200 Subject: Changed git update command --- archinstall.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'archinstall.py') diff --git a/archinstall.py b/archinstall.py index 2e1f30c6..21886b5b 100644 --- a/archinstall.py +++ b/archinstall.py @@ -62,7 +62,7 @@ def update_git(): ## Not the most elegant way to make sure git conflicts doesn't occur (yea fml) os.remove('/root/archinstall/archinstall.py') os.remove('/root/archinstall/README.md') - output = run('git pull') + output = run('git fetch --all') # git reset --hard origin/ if b'error:' in output: print('[N] Could not update git source for some reason.') -- cgit v1.2.3-70-g09d2 From d1c0600ebfa0679edc0aa2a8a9fd0e426170b27a Mon Sep 17 00:00:00 2001 From: Lord Anton Hvornum Date: Sat, 7 Apr 2018 14:35:51 +0200 Subject: print error --- archinstall.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'archinstall.py') diff --git a/archinstall.py b/archinstall.py index 21886b5b..b02616cb 100644 --- a/archinstall.py +++ b/archinstall.py @@ -49,7 +49,7 @@ def run(cmd, echo=False): data = handle.stdout.read() if len(data): if echo: - print(data.decode('UTF-8', end='')) + print(data.decode('UTF-8'), end='') # print(data.decode('UTF-8'), end='') output += data output += handle.stdout.read() -- cgit v1.2.3-70-g09d2 From c68152fb365c2964579322680b905ad096d04112 Mon Sep 17 00:00:00 2001 From: Lord Anton Hvornum Date: Sat, 7 Apr 2018 15:15:31 +0200 Subject: Fixed git fetch, hopefully --- archinstall.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'archinstall.py') diff --git a/archinstall.py b/archinstall.py index b02616cb..f8ebe9fe 100644 --- a/archinstall.py +++ b/archinstall.py @@ -62,7 +62,7 @@ def update_git(): ## Not the most elegant way to make sure git conflicts doesn't occur (yea fml) os.remove('/root/archinstall/archinstall.py') os.remove('/root/archinstall/README.md') - output = run('git fetch --all') # git reset --hard origin/ + output = run('(cd /root/archinstall; git fetch --all)') # git reset --hard origin/ if b'error:' in output: print('[N] Could not update git source for some reason.') -- cgit v1.2.3-70-g09d2 From 88dfcad86c314fc5aa90a508f4e76d666f69099f Mon Sep 17 00:00:00 2001 From: Lord Anton Hvornum Date: Sat, 7 Apr 2018 15:32:28 +0200 Subject: Debugging --- archinstall.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'archinstall.py') diff --git a/archinstall.py b/archinstall.py index f8ebe9fe..57db7958 100644 --- a/archinstall.py +++ b/archinstall.py @@ -53,6 +53,7 @@ def run(cmd, echo=False): # print(data.decode('UTF-8'), end='') output += data output += handle.stdout.read() + print('Command done:', output) handle.stdout.close() return output @@ -62,6 +63,7 @@ def update_git(): ## Not the most elegant way to make sure git conflicts doesn't occur (yea fml) os.remove('/root/archinstall/archinstall.py') os.remove('/root/archinstall/README.md') + # sh -c 'cd /c && ../a/helloworld' output = run('(cd /root/archinstall; git fetch --all)') # git reset --hard origin/ if b'error:' in output: -- cgit v1.2.3-70-g09d2 From 8e22ac18d66b0ec06b8e7923c01876a9a5c95b7f Mon Sep 17 00:00:00 2001 From: Lord Anton Hvornum Date: Sat, 7 Apr 2018 16:28:11 +0200 Subject: more debing --- archinstall.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'archinstall.py') diff --git a/archinstall.py b/archinstall.py index 57db7958..204a5f54 100644 --- a/archinstall.py +++ b/archinstall.py @@ -53,7 +53,7 @@ def run(cmd, echo=False): # print(data.decode('UTF-8'), end='') output += data output += handle.stdout.read() - print('Command done:', output) + print('Command done:', output, handle.poll()) handle.stdout.close() return output @@ -210,7 +210,7 @@ if __name__ == '__main__': o = run('arch-chroot /mnt rm /etc/localtime') o = run('arch-chroot /mnt ln -s /usr/share/zoneinfo/Europe/Stockholm /etc/localtime') o = run('arch-chroot /mnt hwclock --hctosys --localtime') - o = run('arch-chroot /mnt {hostname}'.format(**args)) + o = run('arch-chroot /mnt echo "{hostname}" > /etc/hostname'.format(**args)) o = run("arch-chroot /mnt sed -i 's/#\(en_US\.UTF-8\)/\1/' /etc/locale.gen") o = run('arch-chroot /mnt locale-gen') o = run('arch-chroot /mnt chmod 700 /root') -- cgit v1.2.3-70-g09d2 From 88b50f4dd317629a8ec49d8c127430c2d6a2396d Mon Sep 17 00:00:00 2001 From: Lord Anton Hvornum Date: Sat, 7 Apr 2018 16:51:18 +0200 Subject: Improving the sys exec function --- archinstall.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'archinstall.py') diff --git a/archinstall.py b/archinstall.py index 204a5f54..7fee4220 100644 --- a/archinstall.py +++ b/archinstall.py @@ -41,9 +41,9 @@ def get_local_MACs(): macs[addr.address] = nic return macs -def run(cmd, echo=False): +def run(cmd, echo=False, *args, **kwargs): #print('[!] {}'.format(cmd)) - handle = Popen(cmd, shell='True', stdout=PIPE, stderr=STDOUT) + handle = Popen(cmd, shell='True', stdout=PIPE, stderr=STDOUT, **kwargs) output = b'' while handle.poll() is None: data = handle.stdout.read() @@ -263,8 +263,9 @@ if __name__ == '__main__': for title in instructions: print('[N] {}'.format(title)) for command in instructions[title]: - print('[N] Command: {}'.format(command)) - o = run('arch-chroot /mnt {c}'.format(c=command), echo=True) + opts = instructions[title] if instructions[title] else {} + print('[N] Command: {} ({])'.format(command, opts)) + o = run('arch-chroot /mnt {c}'.format(c=command), echo=True, **opts) if instructions[title][command] and not instructions[title][command] in o: print('[W] Post install command failed: {}'.format(o.decode('UTF-8'))) #print(o) -- cgit v1.2.3-70-g09d2 From d5ba7879438b7df64c101da1f55f433878c797eb Mon Sep 17 00:00:00 2001 From: Lord Anton Hvornum Date: Sat, 7 Apr 2018 17:09:10 +0200 Subject: Debugging --- archinstall.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'archinstall.py') diff --git a/archinstall.py b/archinstall.py index 7fee4220..d16a271c 100644 --- a/archinstall.py +++ b/archinstall.py @@ -218,7 +218,7 @@ if __name__ == '__main__': #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 \'echo "{pin}" | passwd --stdin root\''.format(**args, pin=PIN)) + o = run("arch-chroot /mnt 'echo {pin} | passwd --stdin root".format(pin='"{pin}"'.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)) @@ -264,7 +264,7 @@ if __name__ == '__main__': print('[N] {}'.format(title)) for command in instructions[title]: opts = instructions[title] if instructions[title] else {} - print('[N] Command: {} ({])'.format(command, opts)) + print('[N] Command: {} ({})'.format(command, opts)) o = run('arch-chroot /mnt {c}'.format(c=command), echo=True, **opts) if instructions[title][command] and not instructions[title][command] in o: print('[W] Post install command failed: {}'.format(o.decode('UTF-8'))) -- cgit v1.2.3-70-g09d2 From d02aabbdfd8f60fe3a7f8bf5ca7b4b0531c4608f Mon Sep 17 00:00:00 2001 From: Lord Anton Hvornum Date: Sat, 7 Apr 2018 17:24:29 +0200 Subject: Further debugging --- archinstall.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'archinstall.py') diff --git a/archinstall.py b/archinstall.py index d16a271c..91fb9da1 100644 --- a/archinstall.py +++ b/archinstall.py @@ -263,7 +263,7 @@ if __name__ == '__main__': for title in instructions: print('[N] {}'.format(title)) for command in instructions[title]: - opts = instructions[title] if instructions[title] else {} + opts = instructions[title][command] if instructions[title][command] else {} print('[N] Command: {} ({})'.format(command, opts)) o = run('arch-chroot /mnt {c}'.format(c=command), echo=True, **opts) if instructions[title][command] and not instructions[title][command] in o: -- cgit v1.2.3-70-g09d2 From 88f1f85bf4b50897a080780f5403f7453350672b Mon Sep 17 00:00:00 2001 From: Lord Anton Hvornum Date: Sat, 7 Apr 2018 17:41:47 +0200 Subject: Problem with the optional parameters in the post install script --- archinstall.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'archinstall.py') diff --git a/archinstall.py b/archinstall.py index 91fb9da1..d471f161 100644 --- a/archinstall.py +++ b/archinstall.py @@ -263,10 +263,11 @@ if __name__ == '__main__': for title in instructions: print('[N] {}'.format(title)) for command in instructions[title]: - opts = instructions[title][command] if instructions[title][command] else {} + opts = instructions[title][command] if type(instructions[title][command]) in (dict, oDict) else {} + print('[N] Command: {} ({})'.format(command, opts)) o = run('arch-chroot /mnt {c}'.format(c=command), echo=True, **opts) - if instructions[title][command] and not instructions[title][command] in o: + if len(instructions[title][command]) and type(instructions[title][command]) == bytes and not instructions[title][command] in o: print('[W] Post install command failed: {}'.format(o.decode('UTF-8'))) #print(o) -- cgit v1.2.3-70-g09d2 From 11d782baa6347df81be238daa68a28545d36a848 Mon Sep 17 00:00:00 2001 From: Lord Anton Hvornum Date: Sat, 7 Apr 2018 18:09:59 +0200 Subject: Wrong logical order on command failed logic --- archinstall.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'archinstall.py') diff --git a/archinstall.py b/archinstall.py index d471f161..079e4b5a 100644 --- a/archinstall.py +++ b/archinstall.py @@ -267,7 +267,7 @@ if __name__ == '__main__': print('[N] Command: {} ({})'.format(command, opts)) o = run('arch-chroot /mnt {c}'.format(c=command), echo=True, **opts) - if len(instructions[title][command]) and type(instructions[title][command]) == bytes and not instructions[title][command] in o: + 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) -- cgit v1.2.3-70-g09d2 From f975df7ec2e77eefbeefe4f5f20a655851d5a116 Mon Sep 17 00:00:00 2001 From: Lord Anton Hvornum Date: Sat, 7 Apr 2018 18:27:04 +0200 Subject: more debugging --- archinstall.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'archinstall.py') diff --git a/archinstall.py b/archinstall.py index 079e4b5a..9f185b77 100644 --- a/archinstall.py +++ b/archinstall.py @@ -61,9 +61,8 @@ def update_git(): default_gw = get_default_gateway_linux() if(default_gw): ## Not the most elegant way to make sure git conflicts doesn't occur (yea fml) - os.remove('/root/archinstall/archinstall.py') - os.remove('/root/archinstall/README.md') - # sh -c 'cd /c && ../a/helloworld' + #os.remove('/root/archinstall/archinstall.py') + #os.remove('/root/archinstall/README.md') output = run('(cd /root/archinstall; git fetch --all)') # git reset --hard origin/ if b'error:' in output: -- cgit v1.2.3-70-g09d2 From 13a1c2ab3a1035d22cfe05a9ef1c801daa2a2a82 Mon Sep 17 00:00:00 2001 From: Lord Anton Hvornum Date: Sat, 7 Apr 2018 22:48:14 +0200 Subject: Verified a working network install, removing debugs --- archinstall.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'archinstall.py') diff --git a/archinstall.py b/archinstall.py index 9f185b77..b43c7e2f 100644 --- a/archinstall.py +++ b/archinstall.py @@ -48,12 +48,14 @@ def run(cmd, echo=False, *args, **kwargs): while handle.poll() is None: data = handle.stdout.read() if len(data): - if echo: + if echo and 'flush': print(data.decode('UTF-8'), end='') # print(data.decode('UTF-8'), end='') output += data - output += handle.stdout.read() - print('Command done:', output, handle.poll()) + data = handle.stdout.read() + if echo: + print(data.decode('UTF-8'), end='') + output += data handle.stdout.close() return output @@ -159,6 +161,7 @@ if __name__ == '__main__': with open(args['pwfile'], 'r') as pw: PIN = pw.read().strip() + print() print('[!] Disk PASSWORD is: {}'.format(PIN)) print() print('[N] Setting up {drive}.'.format(**args)) @@ -213,11 +216,13 @@ if __name__ == '__main__': o = run("arch-chroot /mnt sed -i 's/#\(en_US\.UTF-8\)/\1/' /etc/locale.gen") o = run('arch-chroot /mnt locale-gen') 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 'echo {pin} | passwd --stdin root".format(pin='"{pin}"'.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) 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,7 +270,7 @@ if __name__ == '__main__': opts = instructions[title][command] if type(instructions[title][command]) in (dict, oDict) else {} print('[N] Command: {} ({})'.format(command, opts)) - o = run('arch-chroot /mnt {c}'.format(c=command), echo=True, **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) -- cgit v1.2.3-70-g09d2 From 82fe1585529f31445fd14ff7fa933d8d732d678f Mon Sep 17 00:00:00 2001 From: Lord Anton Hvornum Date: Sat, 7 Apr 2018 23:15:32 +0200 Subject: Finalizing working net deploy --- archinstall.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'archinstall.py') diff --git a/archinstall.py b/archinstall.py index b43c7e2f..42096b2a 100644 --- a/archinstall.py +++ b/archinstall.py @@ -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.') -- cgit v1.2.3-70-g09d2 From e395962fe22305755a5dc6b5c3650d12cf5b3604 Mon Sep 17 00:00:00 2001 From: Lord Anton Hvornum Date: Sat, 7 Apr 2018 23:32:49 +0200 Subject: Fixed password change for custom user as well as hostname and locale gen. --- archinstall.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'archinstall.py') diff --git a/archinstall.py b/archinstall.py index 42096b2a..dad42737 100644 --- a/archinstall.py +++ b/archinstall.py @@ -212,8 +212,10 @@ if __name__ == '__main__': o = run('arch-chroot /mnt rm /etc/localtime') o = run('arch-chroot /mnt ln -s /usr/share/zoneinfo/Europe/Stockholm /etc/localtime') o = run('arch-chroot /mnt hwclock --hctosys --localtime') - o = run('arch-chroot /mnt echo "{hostname}" > /etc/hostname'.format(**args)) - o = run("arch-chroot /mnt sed -i 's/#\(en_US\.UTF-8\)/\1/' /etc/locale.gen") + #o = run('arch-chroot /mnt echo "{hostname}" > /etc/hostname'.format(**args)) + #o = run("arch-chroot /mnt sed -i 's/#\(en_US\.UTF-8\)/\1/' /etc/locale.gen") + o = run("arch-chroot /mnt sh -c \"echo '{hostname}' > /etc/hostname\"".format(**args)) + o = run("arch-chroot /mnt sh -c \"echo -n 'en_US.UTF-8' > /etc/locale.gen\"") o = run('arch-chroot /mnt locale-gen') o = run('arch-chroot /mnt chmod 700 /root') @@ -223,7 +225,7 @@ if __name__ == '__main__': 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)) + o = run("arch-chroot /mnt sh -c \"echo '{user}:{pin}' | chpasswd\"".format(**args, pin=PIN)) with open('/mnt/etc/mkinitcpio.conf', 'w') as mkinit: ## TODO: Don't replace it, in case some update in the future actually adds something. -- cgit v1.2.3-70-g09d2