From 014067c1d09dd4a372aaffa930cd3bcbdcc5ba47 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Mon, 10 May 2021 20:42:26 +0000 Subject: [PATCH] Set the first install status in unattended installations Signed-off-by: Michael Tremer --- src/python/__init__.py | 1 + src/python/step.py | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/python/__init__.py b/src/python/__init__.py index 8f2686f..ed77279 100644 --- a/src/python/__init__.py +++ b/src/python/__init__.py @@ -107,6 +107,7 @@ class Bricklayer(object): bootloaders.InstallBootloader, # Done! + step.ToggleFirstInstallStatus, disk.UmountFilesystems, step.Congratulations, ) diff --git a/src/python/step.py b/src/python/step.py index b4eefe8..d4d08a5 100644 --- a/src/python/step.py +++ b/src/python/step.py @@ -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 -- 2.47.3