[rhel7-branch 1/2] Add a systemd service that enables Initial Setup
if
/.unconfigured exists (#1257624)
by dashea
From: Martin Kolman <mkolman(a)redhat.com>
Add a systemd service called initial-setup-reconfiguration.service that automatically starts
initial-setup.service when a file named .unconfigured exists in filesystem root (/).
Initial Setup will then detect the file & start in the reconfiguration mode.
Initial Setup also makes sure to delete the file & disable its service once done.
Resolves: rhbz#1257624
---
initial-setup.spec | 1 +
initial_setup/__init__.py | 54 ++++++++++++++++++++++---------
scripts/reconfiguration-mode-enabled | 3 ++
setup.py | 3 +-
systemd/initial-setup-reconfigure.service | 26 +++++++++++++++
5 files changed, 71 insertions(+), 16 deletions(-)
create mode 100755 scripts/reconfiguration-mode-enabled
create mode 100644 systemd/initial-setup-reconfigure.service
diff --git a/initial-setup.spec b/initial-setup.spec
index a231add..1720a91 100644
--- a/initial-setup.spec
+++ b/initial-setup.spec
@@ -97,6 +97,7 @@ make install-po-files
%exclude %{python_sitelib}/initial_setup/gui
%{_unitdir}/initial-setup-text.service
%{_unitdir}/initial-setup.service
+%{_unitdir}/initial-setup-reconfiguration.service
%{_libexecdir}/%{name}/run-initial-setup
%{_libexecdir}/%{name}/firstboot-windowmanager
%{_libexecdir}/%{name}/initial-setup-text
diff --git a/initial_setup/__init__.py b/initial_setup/__init__.py
index eb02013..e4bd9b8 100644
--- a/initial_setup/__init__.py
+++ b/initial_setup/__init__.py
@@ -29,7 +29,7 @@ class InitialSetupError(Exception):
INPUT_KICKSTART_PATH = "/root/anaconda-ks.cfg"
OUTPUT_KICKSTART_PATH = "/root/initial-setup-ks.cfg"
-RECONFIG_FILE = "/etc/reconfigSys"
+RECONFIG_FILES = ["/etc/reconfigSys", "/.unconfigured"]
SUPPORTED_KICKSTART_COMMANDS = ["user",
"eula",
@@ -47,8 +47,6 @@ class InitialSetupError(Exception):
signal.signal(signal.SIGINT, signal.SIG_IGN)
-external_reconfig = os.path.exists(RECONFIG_FILE)
-
# setup logging
log = logging.getLogger("initial-setup")
@@ -79,7 +77,17 @@ def __init__(self, gui_mode):
else:
log.debug("running in TUI mode")
- if external_reconfig:
+ self._external_reconfig = False
+
+ # check if the reconfig mode should be enabled
+ # by checking if at least one of the reconfig
+ # files exist
+ for reconfig_file in RECONFIG_FILES:
+ if os.path.exists(reconfig_file):
+ self.external_reconfig = True
+ log.debug("reconfig trigger file found: %s", reconfig_file)
+
+ if self.external_reconfig:
log.debug("running in externally triggered reconfig mode")
if self.gui_mode:
@@ -113,6 +121,21 @@ def __init__(self, gui_mode):
setup_ifcfg_log()
@property
+ def external_reconfig(self):
+ """External reconfig status.
+
+ Reports if external (eq. not triggered by kickstart) has been enabled.
+
+ :returns: True if external reconfig mode has been enabled, else False.
+ :rtype: bool
+ """
+ return self._external_reconfig
+
+ @external_reconfig.setter
+ def external_reconfig(self, value):
+ self._external_reconfig = value
+
+ @property
def gui_mode_id(self):
"""String id of the current GUI mode
@@ -162,7 +185,7 @@ def _load_kickstart(self):
log.critical("Initial Setup startup failed due to invalid kickstart file")
raise InitialSetupError
- if external_reconfig:
+ if self.external_reconfig:
# set the reconfig flag in kickstart so that
# relevant spokes show up
self.data.firstboot.firstboot = FIRSTBOOT_RECONFIG
@@ -211,10 +234,10 @@ def _apply(self):
log.info("executing addons")
self.data.addons.execute(None, self.data, None, u, None)
- if external_reconfig:
- # prevent the reconfig flag from being written out,
- # to prevent the reconfig mode from being enabled
- # without the /etc/reconfigSys file being present
+ if self.external_reconfig:
+ # prevent the reconfig flag from being written out
+ # to kickstart if neither /etc/reconfigSys or /.unconfigured
+ # are present
self.data.firstboot.firstboot = None
# Write the kickstart data to file
@@ -223,12 +246,13 @@ def _apply(self):
f.write(str(self.data))
log.info("finished writing the Initial Setup kickstart file")
- # Remove the reconfig file, if any - otherwise the reconfig mode
- # would start again next time the Initial Setup service is enabled
- if external_reconfig and os.path.exists(RECONFIG_FILE):
- log.debug("removing the reconfig file")
- os.remove(RECONFIG_FILE)
- log.debug("the reconfig file has been removed")
+ # Remove the reconfig files, if any - otherwise the reconfig mode
+ # would start again next time the Initial Setup service is enabled.
+ if self.external_reconfig:
+ for reconfig_file in RECONFIG_FILES:
+ if os.path.exists(reconfig_file):
+ log.debug("removing reconfig trigger file: %s" % reconfig_file)
+ os.remove(reconfig_file)
def run(self):
"""Run Initial setup
diff --git a/scripts/reconfiguration-mode-enabled b/scripts/reconfiguration-mode-enabled
new file mode 100755
index 0000000..45f0ba1
--- /dev/null
+++ b/scripts/reconfiguration-mode-enabled
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+echo "The /.unconfigured file has been detected, enabling Initial Setup in reconfiguration mode." | systemd-cat -t initial-setup -p 6
diff --git a/setup.py b/setup.py
index 9676d42..d5e2b28 100644
--- a/setup.py
+++ b/setup.py
@@ -36,7 +36,8 @@ def read(fname):
('/usr/libexec/initial-setup/',
["scripts/run-initial-setup", "scripts/firstboot-windowmanager",
"scripts/initial-setup-text", "scripts/initial-setup-graphical",
- "scripts/graphical-service-is-deprecated", "scripts/text-service-is-deprecated"])]
+ "scripts/graphical-service-is-deprecated", "scripts/text-service-is-deprecated",
+ "reconfiguration-mode-enabled"])]
# add the firstboot start script for s390 architectures
if os.uname()[4].startswith('s390'):
diff --git a/systemd/initial-setup-reconfigure.service b/systemd/initial-setup-reconfigure.service
new file mode 100644
index 0000000..b14cac6
--- /dev/null
+++ b/systemd/initial-setup-reconfigure.service
@@ -0,0 +1,26 @@
+[Unit]
+Description=Initial Setup reconfiguration mode trigger service
+After=livesys.service plymouth-quit-wait.service
+After=systemd-vconsole-setup.service
+Before=display-manager.service getty(a)tty1.service getty(a)ttyUSB0.service
+Before=serial-getty(a)ttyS0.service serial-getty(a)ttyO0.service serial-getty(a)ttyO2.service
+Before=serial-getty(a)ttyAMA0.service serial-getty(a)ttymxc0.service serial-getty(a)ttymxc3.service serial-getty(a)hvc0.service
+Before=initial-setup.service
+Conflicts=plymouth-quit-wait.service
+ConditionKernelCommandLine=!rd.live.image
+ConditionPathExists=/.unconfigured
+Requires=initial-setup.service
+
+[Service]
+Type=oneshot
+TimeoutSec=0
+StandardInput=tty
+StandardOutput=tty
+RemainAfterExit=yes
+ExecStart=/usr/libexec/initial-setup/reconfiguration-mode-enabled
+TimeoutSec=0
+RemainAfterExit=no
+
+[Install]
+WantedBy=graphical.target
+WantedBy=multi-user.target
--
To view this commit on github, visit https://github.com/rhinstaller/initial-setup/commit/1dfa45a20f24f3f55945e...
7 years, 11 months
[rhel7-branch 2/2] Some typo fixes and logging improvements
by dashea
From: Martin Kolman <mkolman(a)redhat.com>
Related: rhbz#1257624
---
initial_setup/__init__.py | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/initial_setup/__init__.py b/initial_setup/__init__.py
index e4bd9b8..1607845 100644
--- a/initial_setup/__init__.py
+++ b/initial_setup/__init__.py
@@ -140,7 +140,7 @@ def gui_mode_id(self):
"""String id of the current GUI mode
:returns: "gui" if gui_mode is True, "tui" otherwise
- :rtype str:
+ :rtype: str
"""
if self.gui_mode:
return "gui"
@@ -204,6 +204,8 @@ def _apply(self):
# Do not execute sections that were part of the original
# anaconda kickstart file (== have .seen flag set)
+ log.info("applying changes")
+
sections = [self.data.keyboard, self.data.lang, self.data.timezone]
# data.selinux
@@ -254,12 +256,15 @@ def _apply(self):
log.debug("removing reconfig trigger file: %s" % reconfig_file)
os.remove(reconfig_file)
+ # and we are done with applying changes
+ log.info("all changes have been applied")
+
def run(self):
"""Run Initial setup
GUI will be used when the gui_mode property is True (TUI mode is the default).
- :returns: True if the IS run was successfull, False if it failed
+ :returns: True if the IS run was successful, False if it failed
:rtype: bool
"""
@@ -295,7 +300,7 @@ def run(self):
log.debug("initializing TUI")
ui = initial_setup.tui.InitialSetupTextUserInterface(None, None, None)
- # Pass the data object to user inteface
+ # Pass the data object to user interface
log.debug("setting up the UI")
ui.setup(self.data)
--
To view this commit on github, visit https://github.com/rhinstaller/initial-setup/commit/e5db815c523262b770898...
7 years, 11 months
[PATCH] Fix pylint errors.
by Chris Lumens
---
pyanaconda/kickstart.py | 2 +-
pyanaconda/ui/helpers.py | 8 ++++++++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/pyanaconda/kickstart.py b/pyanaconda/kickstart.py
index 628e592..5ee133f 100644
--- a/pyanaconda/kickstart.py
+++ b/pyanaconda/kickstart.py
@@ -19,7 +19,7 @@
#
from pyanaconda.errors import ScriptError, errorHandler
-from blivet.deviceaction import ActionCreateFormat, ActionDestroyFormat, ActionResizeDevice, ActionResizeFormat
+from blivet.deviceaction import ActionCreateFormat, ActionResizeDevice, ActionResizeFormat
from blivet.devices import LUKSDevice
from blivet.devices.lvm import LVMVolumeGroupDevice, LVMCacheRequest
from blivet.devicelibs.lvm import LVM_PE_SIZE, KNOWN_THPOOL_PROFILES
diff --git a/pyanaconda/ui/helpers.py b/pyanaconda/ui/helpers.py
index 3301b91..e82895e 100644
--- a/pyanaconda/ui/helpers.py
+++ b/pyanaconda/ui/helpers.py
@@ -114,6 +114,14 @@ class SourceSwitchHandler(object, metaclass=ABCMeta):
def storage(self):
pass
+ @abstractproperty
+ def payload(self):
+ pass
+
+ @abstractproperty
+ def instclass(self):
+ pass
+
def __init__(self):
self._device = None
self._current_iso_path = None
--
2.4.3
7 years, 11 months
[PATCH rhel7-branch] Don't mark an empty string for translation.
by Chris Lumens
This will return all the gettext header junk, which is never something
we want to display.
Related: rhbz#1255094
---
pyanaconda/packaging/yumpayload.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pyanaconda/packaging/yumpayload.py b/pyanaconda/packaging/yumpayload.py
index 542e8af..050e953 100644
--- a/pyanaconda/packaging/yumpayload.py
+++ b/pyanaconda/packaging/yumpayload.py
@@ -1457,7 +1457,7 @@ reposdir=%s
progress_map = {
"PROGRESS_PREP" : _("Preparing transaction from installation source"),
"PROGRESS_INSTALL" : _("Installing"),
- "PROGRESS_RETRY" : _(""),
+ "PROGRESS_RETRY" : "",
"PROGRESS_POST" : _("Performing post-installation setup tasks")
}
--
2.4.3
7 years, 11 months