From 6c0f0fb19577dfeb61df3a50b71c18edc6c8ecbf Mon Sep 17 00:00:00 2001 From: brent s Date: Wed, 20 Jan 2021 23:55:11 -0500 Subject: [PATCH] cleaned up boot entries in relchk, added todo for bootsync --- TODO | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 TODO diff --git a/TODO b/TODO new file mode 100644 index 0000000..fc87f60 --- /dev/null +++ b/TODO @@ -0,0 +1,47 @@ +Incorporate prep.txt with config file? +should look something like this: + +#!/usr/bin/env python + +import os +import re +import shutil +import subprocess + +esp = {'/dev/vdb': ('Arch (Fallback)', '/mnt/boot2'), + '/dev/vda': ('Arch', '/mnt/boot1')} +part = 1 + +for dev, (label, mnt) in esp.items(): + grubdir = os.path.join(mnt, 'grub') + if os.path.isdir(grubdir): + shutil.rmtree(grubdir) + efi = subprocess.run(['efibootmgr'], stdout = subprocess.PIPE) + efi_lines = efi.stdout.decode('utf-8').strip().splitlines() + efi_entries = {} + for l in efi_lines: + i = l.split(None, 1) + k = i[1].strip() + v = re.sub(r'^Boot(?P[A-Fa-f0-9]+).*$', r'\g', i[0]) + efi_entries[k] = v + boot_id = efi_entries.get(label) + if not boot_id: + print('Could not find {0}'.format(label)) + else: + cmd = subprocess.run(['efibootmgr', + '-b', boot_id, + '-B'], + stdout = subprocess.PIPE) + cmd = subprocess.run(['grub-install', + '--boot-directory={0}'.format(mnt), + '--bootloader-id=Arch', + '--efi-directory={0}'.format(mnt), + '--target=x86_64-efi', + '--no-nvram', + '--recheck']) + cmd = subprocess.run(['efibootmgr', + '--create', + '--disk', dev, + '--part', str(part), + '--loader', '/EFI/Arch/grubx64.efi', + '--label', label])