diff --git a/bootsync.py b/bootsync.py index 6c2f1c2..4b0d2ee 100755 --- a/bootsync.py +++ b/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'(? @@ -120,4 +120,4 @@ - \ No newline at end of file + diff --git a/sample.config.xml b/sample.config.xml index b55a8ed..05767d2 100644 --- a/sample.config.xml +++ b/sample.config.xml @@ -5,8 +5,8 @@ SEE prep.txt FOR WHAT MUST BE DONE BEFORE RUNNING BOOTSYNC. --> + xmlns="http://git.square-r00t.net/BootSync/" + xsi:schemaLocation="http://git.square-r00t.net/BootSync/plain/bootsync.xsd"> @@ -84,7 +84,10 @@ SEE prep.txt FOR WHAT MUST BE DONE BEFORE RUNNING BOOTSYNC. + - + +