|
|
|
@ -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 = []
|
|
|
|
|