This patch set adds initial support for running Initial setup in an externally triggered reconfig mode. It's making use of the already preset reconfig mode (used for example on Fedora ARM images) that can be enabled from kickstart but makes it possible to trigger it externally without the need to touch the kickstart generated by Anaconda.
How to use this: 1) touch /etc/reconfigSys 2) systemctl enable initial-setup-graphical.service 3) reboot 4) reconfigure your system 5) click on the "finish configuration" button 6) reboot
Why "/etc/reconfigSys" ?
Looks like we have been using this file some time in the past[0] to trigger a system reconfiguration, so I've decided to reuse the same path.
[0] http://web.mit.edu/~linux/rh-7.1/src/cmu_installer/anaconda-7.1/docs/reconfi...
Martin Kolman (3): Add support for externally triggered reconfig mode (#1110439) Read the kickstart from previous IS if available (#1110439) Don't show the EULA spoke in reconfig mode if license is already accepted (#1110439)
initial_setup/__main__.py | 35 +++++++++++++++++++++++++++++++++-- initial_setup/gui/spokes/eula.py | 7 ++++++- 2 files changed, 39 insertions(+), 3 deletions(-)
Make it possible to trigger the already present reconfig mode by by creating the /etc/reconfigSys file, enabling the respektive Initial Setup service and rebooting.
Resolves: rhbz#1110439 Signed-off-by: Martin Kolman mkolman@redhat.com --- initial_setup/__main__.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
diff --git a/initial_setup/__main__.py b/initial_setup/__main__.py index d9e411f..120ae0c 100644 --- a/initial_setup/__main__.py +++ b/initial_setup/__main__.py @@ -8,15 +8,19 @@ from pyanaconda.users import Users from initial_setup.post_installclass import PostInstallClass from initial_setup import initial_setup_log from pyanaconda import iutil +from pykickstart.constants import FIRSTBOOT_RECONFIG
INPUT_KICKSTART_PATH = "/root/anaconda-ks.cfg" OUTPUT_KICKSTART_PATH = "/root/initial-setup-ks.cfg" +RECONFIG_FILE = "/etc/reconfigSys"
# set root to "/", we are now in the installed system iutil.setSysroot("/")
signal.signal(signal.SIGINT, signal.SIG_IGN)
+external_reconfig = os.path.exists(RECONFIG_FILE) + initial_setup_log.init() log = logging.getLogger("initial-setup")
@@ -27,6 +31,9 @@ else:
log.debug("display mode detected: %s", mode)
+if external_reconfig: + log.debug("running in externally triggered reconfig mode") + if mode == "gui": # We need this so we can tell GI to look for overrides objects # also in anaconda source directories @@ -94,6 +101,11 @@ except pykickstart.errors.KickstartError as kserr: log.exception("kickstart parsing failed: %s" % kserr) sys.exit(1)
+if external_reconfig: + # set the reconfig flag in kickstart so that + # relevant spokes show up + data.firstboot.firstboot = FIRSTBOOT_RECONFIG + if mode == "gui": try: # Try to import IS gui specifics @@ -175,8 +187,22 @@ for section in sections: log.info("executing addons") data.addons.execute(None, data, None, u)
+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 + data.firstboot.firstboot = None + # Write the kickstart data to file log.info("writing the Initial Setup kickstart file %s", OUTPUT_KICKSTART_PATH) with open(OUTPUT_KICKSTART_PATH, "w") as f: f.write(str(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") +
On Wed, Jul 01, 2015 at 02:01:54PM +0200, Martin Kolman wrote:
Make it possible to trigger the already present reconfig mode by by creating the /etc/reconfigSys file, enabling the respektive Initial Setup
spelling: respective
service and rebooting.
Looks good other than that.
On Wed, 2015-07-01 at 10:04 -0700, Brian C. Lane wrote:
On Wed, Jul 01, 2015 at 02:01:54PM +0200, Martin Kolman wrote:
Make it possible to trigger the already present reconfig mode by by creating the /etc/reconfigSys file, enabling the respektive Initial Setup
spelling: respective
service and rebooting.
Looks good other than that.
Fixing locally! :)
If there is a kickstart from a previous IS run use it instead of the Anaconda generated one. Otherwise changes done in Initial Setup (such as accepting the EULA) will not be visible in subsequent IS runs.
Related: rhbz#1110439 Signed-off-by: Martin Kolman mkolman@redhat.com --- initial_setup/__main__.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/initial_setup/__main__.py b/initial_setup/__main__.py index 120ae0c..5e80f9b 100644 --- a/initial_setup/__main__.py +++ b/initial_setup/__main__.py @@ -91,11 +91,16 @@ commandMap = dict((k, kickstart.commandMap[k]) for k in kickstart_commands) # Prepare new data object data = kickstart.AnacondaKSHandler(addon_module_paths["ks"], commandUpdates=commandMap)
-log.info("parsing input kickstart %s", INPUT_KICKSTART_PATH) +kickstart_path = INPUT_KICKSTART_PATH +if os.path.exists(OUTPUT_KICKSTART_PATH): + log.info("using kickstart from previous run for input") + kickstart_path = OUTPUT_KICKSTART_PATH + +log.info("parsing input kickstart %s", kickstart_path) try: # Read the installed kickstart parser = kickstart.AnacondaKSParser(data) - parser.readKickstart(INPUT_KICKSTART_PATH) + parser.readKickstart(kickstart_path) log.info("kickstart parsing done") except pykickstart.errors.KickstartError as kserr: log.exception("kickstart parsing failed: %s" % kserr)
It doesn't make sense to show it again if the license has already been accepted during a previous Initial Setup run.
Related: rhbz#1110439 Signed-off-by: Martin Kolman mkolman@redhat.com --- initial_setup/gui/spokes/eula.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/initial_setup/gui/spokes/eula.py b/initial_setup/gui/spokes/eula.py index 342910f..fa08538 100644 --- a/initial_setup/gui/spokes/eula.py +++ b/initial_setup/gui/spokes/eula.py @@ -6,6 +6,7 @@ import logging from pyanaconda.ui.common import FirstbootOnlySpokeMixIn from pyanaconda.ui.gui.spokes import NormalSpoke from pyanaconda.constants import FIRSTBOOT_ENVIRON +from pykickstart.constants import FIRSTBOOT_RECONFIG
from initial_setup.product import get_license_file_name from initial_setup.common import LicensingCategory @@ -96,8 +97,12 @@ class EULAspoke(FirstbootOnlySpokeMixIn, NormalSpoke):
@classmethod def should_run(cls, environment, data): - # the EULA spoke should always run, but only in Initial Setup + # the EULA spoke should only run in Initial Setup if environment == FIRSTBOOT_ENVIRON: + # don't run if we are in reconfig mode and the EULA has already been accepted + if data and data.firstboot.firstboot == FIRSTBOOT_RECONFIG and data.eula.agreed: + log.debug("not running license spoke: reconfig mode & license already accepted") + return False return True
def on_check_button_toggled(self, checkbutton, *args):
On Wed, 2015-07-01 at 14:01 +0200, Martin Kolman wrote:
It doesn't make sense to show it again if the license has already been accepted during a previous Initial Setup run.
Related: rhbz#1110439 Signed-off-by: Martin Kolman mkolman@redhat.com
initial_setup/gui/spokes/eula.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/initial_setup/gui/spokes/eula.py b/initial_setup/gui/spokes/eula.py index 342910f..fa08538 100644 --- a/initial_setup/gui/spokes/eula.py +++ b/initial_setup/gui/spokes/eula.py @@ -6,6 +6,7 @@ import logging from pyanaconda.ui.common import FirstbootOnlySpokeMixIn from pyanaconda.ui.gui.spokes import NormalSpoke from pyanaconda.constants import FIRSTBOOT_ENVIRON +from pykickstart.constants import FIRSTBOOT_RECONFIG
from initial_setup.product import get_license_file_name from initial_setup.common import LicensingCategory @@ -96,8 +97,12 @@ class EULAspoke(FirstbootOnlySpokeMixIn, NormalSpoke):
@classmethod def should_run(cls, environment, data):
# the EULA spoke should always run, but only in Initial Setup
# the EULA spoke should only run in Initial Setup if environment == FIRSTBOOT_ENVIRON:
# don't run if we are in reconfig mode and the EULA has already been accepted
if data and data.firstboot.firstboot == FIRSTBOOT_RECONFIG and data.eula.agreed:
log.debug("not running license spoke: reconfig mode & license already accepted")
return False return True
I think this needs to be done for the TUI EULA spoke too.
On Fri, 2015-07-03 at 09:07 +0200, Vratislav Podzimek wrote:
On Wed, 2015-07-01 at 14:01 +0200, Martin Kolman wrote:
It doesn't make sense to show it again if the license has already been accepted during a previous Initial Setup run.
Related: rhbz#1110439 Signed-off-by: Martin Kolman mkolman@redhat.com
initial_setup/gui/spokes/eula.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/initial_setup/gui/spokes/eula.py b/initial_setup/gui/spokes/eula.py index 342910f..fa08538 100644 --- a/initial_setup/gui/spokes/eula.py +++ b/initial_setup/gui/spokes/eula.py @@ -6,6 +6,7 @@ import logging from pyanaconda.ui.common import FirstbootOnlySpokeMixIn from pyanaconda.ui.gui.spokes import NormalSpoke from pyanaconda.constants import FIRSTBOOT_ENVIRON +from pykickstart.constants import FIRSTBOOT_RECONFIG
from initial_setup.product import get_license_file_name from initial_setup.common import LicensingCategory @@ -96,8 +97,12 @@ class EULAspoke(FirstbootOnlySpokeMixIn, NormalSpoke):
@classmethod def should_run(cls, environment, data):
# the EULA spoke should always run, but only in Initial
Setup
# the EULA spoke should only run in Initial Setup if environment == FIRSTBOOT_ENVIRON:
# don't run if we are in reconfig mode and the EULA
has already been accepted
if data and data.firstboot.firstboot ==
FIRSTBOOT_RECONFIG and data.eula.agreed:
log.debug("not running license spoke: reconfig
mode & license already accepted")
return False return True
I think this needs to be done for the TUI EULA spoke too.
Oh, right - fixing locally. :)
anaconda-patches@lists.fedorahosted.org