i think i might have something that works here...
This commit is contained in:
parent
27ac49a065
commit
7249d88bad
23
bootsync.py
23
bootsync.py
@ -65,7 +65,7 @@ class BootSync(object):
|
||||
self.schema = url.read()
|
||||
self.schema = etree.XMLSchema(etree.XML(self.schema))
|
||||
self.schema.assertValid(self.xml)
|
||||
return()
|
||||
return(None)
|
||||
|
||||
def chkMounts(self, dryrun = False):
|
||||
if not dryrun:
|
||||
@ -87,20 +87,20 @@ class BootSync(object):
|
||||
stderr = devnull)
|
||||
elif c.returncode == 32: # Already mounted
|
||||
pass
|
||||
return()
|
||||
return(None)
|
||||
|
||||
def chkReboot(self):
|
||||
self._getInstalledKernel()
|
||||
if not self.kernelFile:
|
||||
return() # No isKernel="true" was specified in the config.
|
||||
return() # No 'isKernel="true"' attribute was specified in the config.
|
||||
if self.installedKernVer != self.currentKernVer:
|
||||
self.RequireReboot = True
|
||||
# TODO: logger instead?
|
||||
print(('NOTE: REBOOT REQUIRED. '
|
||||
'New kernel is {0}. '
|
||||
'Running kernel is {1}.').format(self.installedKernVer,
|
||||
self.currentKernVer))
|
||||
return()
|
||||
self.currentKernVer))
|
||||
return(None)
|
||||
|
||||
def getBlkids(self):
|
||||
cmd = ['/usr/bin/blkid',
|
||||
@ -129,12 +129,10 @@ class BootSync(object):
|
||||
cmd = ['/usr/bin/findmnt',
|
||||
'--json',
|
||||
'-T', '/boot']
|
||||
# if os.geteuid() != 0:
|
||||
# cmd.insert(0, 'sudo')
|
||||
c = subprocess.run(cmd,
|
||||
stdout = subprocess.PIPE)
|
||||
self.dummy_uuid = self.blkids[json.loads(c.stdout.decode('utf-8'))['filesystems'][0]['source']]
|
||||
return()
|
||||
return(None)
|
||||
|
||||
def getChecks(self):
|
||||
# Get the default hashtype (if one exists)
|
||||
@ -155,7 +153,7 @@ class BootSync(object):
|
||||
if rel_fpath not in self.syncs:
|
||||
self.syncs[rel_fpath] = []
|
||||
self.syncs[rel_fpath].append(mount)
|
||||
return()
|
||||
return(None)
|
||||
|
||||
def sync(self, dryrun = False, *args, **kwargs):
|
||||
if not dryrun:
|
||||
@ -206,7 +204,6 @@ class BootSync(object):
|
||||
shutil.copy2(bootsource, bootfile)
|
||||
return()
|
||||
|
||||
|
||||
def writeConfs(self, dryrun = False, *args, **kwargs):
|
||||
if not dryrun:
|
||||
if os.geteuid() != 0:
|
||||
@ -231,12 +228,12 @@ class BootSync(object):
|
||||
# If the array is in a degraded state, this will still let us at LEAST boot.
|
||||
line = re.sub(r'\s+--hint=[\'"]?mduuid/[a-f0-9]{32}[\'"]?', '', line)
|
||||
line = re.sub(r'^(\s*set\s+root=){0}$'.format(self.dummy_uuid),
|
||||
self.blkids[disk],
|
||||
r'\g<1>{0}'.format(self.blkids[disk]),
|
||||
line)
|
||||
line = re.sub(r'(?<!\=UUID\=){0}'.format(self.dummy_uuid),
|
||||
self.blkids[disk],
|
||||
line)
|
||||
line = re.sub('(^\s*|\s+)/boot', '', line)
|
||||
line = re.sub(r'(^\s*|\s+)/boot', '', line)
|
||||
f.write('{0}\n'.format(line))
|
||||
return()
|
||||
|
||||
@ -252,7 +249,7 @@ class BootSync(object):
|
||||
_hash = hasher()
|
||||
with open(fpathname, 'rb') as fh:
|
||||
_hash.update(fh.read())
|
||||
return (_hash.hexdigest())
|
||||
return(_hash.hexdigest())
|
||||
|
||||
def _getRunningKernel(self):
|
||||
_vers = []
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
||||
targetNamespace="http://git.square-r00t.net/OpTools/tree/sys/BootSync/"
|
||||
xmlns="http://git.square-r00t.net/OpTools/tree/sys/BootSync/"
|
||||
xmlns:bootsync="http://git.square-r00t.net/OpTools/tree/sys/BootSync/"
|
||||
targetNamespace="http://git.square-r00t.net/BootSync/"
|
||||
xmlns="http://git.square-r00t.net/BootSync/"
|
||||
xmlns:bootsync="http://git.square-r00t.net/BootSync/"
|
||||
elementFormDefault="qualified"
|
||||
attributeFormDefault="unqualified">
|
||||
|
||||
|
@ -5,8 +5,8 @@
|
||||
SEE prep.txt FOR WHAT MUST BE DONE BEFORE RUNNING BOOTSYNC.
|
||||
-->
|
||||
<bootsync xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://git.square-r00t.net/OpTools/tree/sys/BootSync/"
|
||||
xsi:schemaLocation="http://git.square-r00t.net/OpTools/plain/sys/BootSync/bootsync.xsd">
|
||||
xmlns="http://git.square-r00t.net/BootSync/"
|
||||
xsi:schemaLocation="http://git.square-r00t.net/BootSync/plain/bootsync.xsd">
|
||||
<!-- The actual EFI System Partitions (ESP). At least two are required. -->
|
||||
<!-- Each drive should be prepared ahead of time with efibootmgr and grub-install (see prep.txt). -->
|
||||
<partitions>
|
||||
@ -84,7 +84,10 @@ SEE prep.txt FOR WHAT MUST BE DONE BEFORE RUNNING BOOTSYNC.
|
||||
<path source="/usr/lib/grub/x86_64-efi" target="grub/x86_64-efi" pattern="^.*\.(mod|lst|sh)$"/>
|
||||
<!-- And these are ISO files, in case you're like me and do loop mounting in Grub for rescue situations.
|
||||
(e.g. https://wiki.archlinux.org/index.php/Multiboot_USB_drive#Using_GRUB_and_loopback_devices) -->
|
||||
<!-- You can do this yourself easily via https://git.square-r00t.net/RelChk/ -->
|
||||
<!-- <path hashtype="false" source="/boot/iso" target="iso" pattern="^.*\.(iso|img)$"/> -->
|
||||
<path hashtype="md5" source="/boot/iso" target="iso" pattern=".*"/>
|
||||
<!-- I use RelChk (see above), so I also copy over the .json files that contain easily accessible information
|
||||
about the ISO images. -->
|
||||
<path hashtype="md5" source="/boot/iso" target="iso" pattern="^.*\.(iso|img|json)$"/>
|
||||
</syncPaths>
|
||||
</bootsync>
|
||||
|
Loading…
Reference in New Issue
Block a user