From 66e79dc8a0e93e2d8effc259584d22379523d476 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Mon, 10 May 2021 19:57:33 +0000 Subject: [PATCH] Add "first install" mode to do configuration later Signed-off-by: Michael Tremer --- src/bricklayer | 2 ++ src/python/__init__.py | 7 ++++++- src/python/step.py | 10 ++++++++++ src/python/timezones.py | 2 ++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/bricklayer b/src/bricklayer index f64ba4b..b0d3a4c 100644 --- a/src/bricklayer +++ b/src/bricklayer @@ -40,6 +40,8 @@ class Cli(object): parser = argparse.ArgumentParser( description=_("IPFire Installation Tool CLI"), ) + parser.add_argument("--first-install", action="store_true", + help=_("Runs the \"first install\" setup process")) parser.add_argument("--arch", nargs="?", default=self.native_arch, help=_("Select the target architecture")) parser.add_argument("--debug", action="store_true", diff --git a/src/python/__init__.py b/src/python/__init__.py index e1b1c48..8f2686f 100644 --- a/src/python/__init__.py +++ b/src/python/__init__.py @@ -45,8 +45,9 @@ class Bricklayer(object): """ Bricklayer's base class """ - def __init__(self, arch, debug=False, unattended=False, disks=[]): + def __init__(self, arch, first_install=False, debug=False, unattended=False, disks=[]): self.arch = arch + self.first_install = first_install self.unattended = unattended # Enable debug logging @@ -182,6 +183,10 @@ class Bricklayer(object): # Initialize the step step = stepcls(self, tui=self.tui) + # Skip this step if it isn't enabled in first install mode + if self.first_install and not step.first_install: + return + # Skip this step if it isn't enabled if not step.enabled: return diff --git a/src/python/step.py b/src/python/step.py index c00c94a..b4eefe8 100644 --- a/src/python/step.py +++ b/src/python/step.py @@ -39,6 +39,9 @@ class Step(object): # This enables or disables this step enabled = True + # Should this be run in first-install mode? + first_install = False + def __init__(self, bricklayer, tui): self.bricklayer = bricklayer self.tui = tui @@ -131,6 +134,8 @@ class Welcome(InteractiveStep): """ Shows a very warm welcome message to the user """ + first_install = True + def run(self): name = self.bricklayer.os.get("NAME") current_language = self.bricklayer.settings.get("language") @@ -156,6 +161,8 @@ class Congratulations(InteractiveStep): """ Shows a message that the installation is complete """ + first_install = True + def run(self): self.tui.message( _("Congratulations"), @@ -170,6 +177,7 @@ class Congratulations(InteractiveStep): width=50, ) + class UnattendedWarning(Step): @property def enabled(self): @@ -193,6 +201,8 @@ class UnattendedWarning(Step): class RootPassword(InteractiveStep): + first_install = True + def run(self): password = self.tui.passwd( _("Root Password"), diff --git a/src/python/timezones.py b/src/python/timezones.py index adb15bf..7e3b245 100644 --- a/src/python/timezones.py +++ b/src/python/timezones.py @@ -28,6 +28,8 @@ from .i18n import _ log = logging.getLogger("bricklayer.timezones") class SelectTimezone(step.InteractiveStep): + first_install = True + def run(self): # Get a list of all available timezones timezones = { -- 2.47.3