]> git.ipfire.org Git - people/ms/bricklayer.git/commitdiff
Set the first install status in unattended installations
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 10 May 2021 20:42:26 +0000 (20:42 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 10 May 2021 20:42:26 +0000 (20:42 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/python/__init__.py
src/python/step.py

index 8f2686fd8d6a8ee547980619ee87e25c7d40109d..ed772797f66c22d55f327d5e812cd02a3efce836 100644 (file)
@@ -107,6 +107,7 @@ class Bricklayer(object):
                bootloaders.InstallBootloader,
 
                # Done!
+               step.ToggleFirstInstallStatus,
                disk.UmountFilesystems,
                step.Congratulations,
        )
index b4eefe845df203f4d547e17a25118f161041fc84..d4d08a59a5468eea4b1b00940add037a68aa47cc 100644 (file)
@@ -211,3 +211,28 @@ class RootPassword(InteractiveStep):
 
                # Save the password for now
                self.bricklayer.settings["root-password"] = password
+
+
+class ToggleFirstInstallStatus(Step):
+       first_install = True
+
+       @property
+       def enabled(self):
+               # Only enabled in unattended and first install mode
+               return self.bricklayer.unattended or self.bricklayer.first_install
+
+       def run(self):
+               # Path to the marker file
+               path = os.path.join(self.bricklayer.root, ".firstinstall")
+
+               # Create file in unattended mode
+               if self.bricklayer.unattended:
+                       with open(path, "w"):
+                               pass
+
+               # Remove the file in first install mode
+               elif self.bricklayer.first_install:
+                       try:
+                               os.unlink(path)
+                       except FileNotFoundError:
+                               pass