summaryrefslogtreecommitdiffstats
path: root/rescue.py
diff options
context:
space:
mode:
authorAlexander Todorov <atodorov@redhat.com>2008-07-29 15:54:44 +0300
committerChris Lumens <clumens@redhat.com>2008-08-11 13:07:06 -0400
commit5a7c4385f4c9c0ca28b4e7bace86a36ca147be7b (patch)
treeb6d4fa92d11c01cee7bcf0581d31b32b9db31dbf /rescue.py
parent4d6b86392daa7aa34233db2387523e6a6e033326 (diff)
downloadanaconda-5a7c4385f4c9c0ca28b4e7bace86a36ca147be7b.tar.gz
anaconda-5a7c4385f4c9c0ca28b4e7bace86a36ca147be7b.tar.xz
anaconda-5a7c4385f4c9c0ca28b4e7bace86a36ca147be7b.zip
Handle 'rescue' and %post in rescue mode
All changes to handle the new rescue command and %post scripts when in rescue mode.
Diffstat (limited to 'rescue.py')
-rw-r--r--rescue.py135
1 files changed, 83 insertions, 52 deletions
diff --git a/rescue.py b/rescue.py
index 3f77e75cc..028471cc6 100644
--- a/rescue.py
+++ b/rescue.py
@@ -277,40 +277,53 @@ def runRescue(anaconda, instClass):
# Early shell access with no disk access attempts
if not anaconda.rescue_mount:
- runShell()
- sys.exit(0)
+ # the %post should be responsible for mounting all needed file systems
+ # NOTE: 1st script must be bash or simple python as nothing else might be available in the rescue image
+ if anaconda.isKickstart:
+ from kickstart import runPostScripts
+ runPostScripts(anaconda)
+ else:
+ runShell()
- screen = SnackScreen()
- anaconda.intf = RescueInterface(screen)
-
- # prompt to see if we should try and find root filesystem and mount
- # everything in /etc/fstab on that root
- rc = ButtonChoiceWindow(screen, _("Rescue"),
- _("The rescue environment will now attempt to find your "
- "Linux installation and mount it under the directory "
- "%s. You can then make any changes required to your "
- "system. If you want to proceed with this step choose "
- "'Continue'. You can also choose to mount your file systems "
- "read-only instead of read-write by choosing 'Read-Only'."
- "\n\n"
- "If for some reason this process fails you can choose 'Skip' "
- "and this step will be skipped and you will go directly to a "
- "command shell.\n\n") % (anaconda.rootPath,),
- [_("Continue"), _("Read-Only"), _("Skip")] )
-
- if rc == string.lower(_("Skip")):
- runShell(screen)
sys.exit(0)
- elif rc == string.lower(_("Read-Only")):
- readOnly = 1
+
+ if anaconda.isKickstart:
+ if anaconda.id.ksdata.rescue and anaconda.id.ksdata.rescue.romount:
+ readOnly = 1
+ else:
+ readOnly = 0
else:
- readOnly = 0
+ screen = SnackScreen()
+ anaconda.intf = RescueInterface(screen)
+
+ # prompt to see if we should try and find root filesystem and mount
+ # everything in /etc/fstab on that root
+ rc = ButtonChoiceWindow(screen, _("Rescue"),
+ _("The rescue environment will now attempt to find your "
+ "Linux installation and mount it under the directory "
+ "%s. You can then make any changes required to your "
+ "system. If you want to proceed with this step choose "
+ "'Continue'. You can also choose to mount your file systems "
+ "read-only instead of read-write by choosing 'Read-Only'."
+ "\n\n"
+ "If for some reason this process fails you can choose 'Skip' "
+ "and this step will be skipped and you will go directly to a "
+ "command shell.\n\n") % (anaconda.rootPath,),
+ [_("Continue"), _("Read-Only"), _("Skip")] )
+
+ if rc == string.lower(_("Skip")):
+ runShell(screen)
+ sys.exit(0)
+ elif rc == string.lower(_("Read-Only")):
+ readOnly = 1
+ else:
+ readOnly = 0
disks = upgrade.findExistingRoots(anaconda, upgradeany = 1)
if not disks:
root = None
- elif len(disks) == 1:
+ elif (len(disks) == 1) or anaconda.isKickstart:
root = disks[0]
else:
height = min (len (disks), 12)
@@ -352,22 +365,28 @@ def runRescue(anaconda, instClass):
readOnly = readOnly)
if rc == -1:
- ButtonChoiceWindow(screen, _("Rescue"),
- _("Your system had dirty file systems which you chose not "
- "to mount. Press return to get a shell from which "
- "you can fsck and mount your partitions. The system "
- "will reboot automatically when you exit from the "
- "shell."), [_("OK")], width = 50)
+ if anaconda.isKickstart:
+ log.error("System had dirty file systems which you chose not to mount")
+ else:
+ ButtonChoiceWindow(screen, _("Rescue"),
+ _("Your system had dirty file systems which you chose not "
+ "to mount. Press return to get a shell from which "
+ "you can fsck and mount your partitions. The system "
+ "will reboot automatically when you exit from the "
+ "shell."), [_("OK")], width = 50)
rootmounted = 0
else:
- ButtonChoiceWindow(screen, _("Rescue"),
- _("Your system has been mounted under %s.\n\n"
- "Press <return> to get a shell. If you would like to "
- "make your system the root environment, run the command:\n\n"
- "\tchroot %s\n\nThe system will reboot "
- "automatically when you exit from the shell.") %
- (anaconda.rootPath, anaconda.rootPath),
- [_("OK")] )
+ if anaconda.isKickstart:
+ log.info("System has been mounted under: %s" % anaconda.rootPath)
+ else:
+ ButtonChoiceWindow(screen, _("Rescue"),
+ _("Your system has been mounted under %s.\n\n"
+ "Press <return> to get a shell. If you would like to "
+ "make your system the root environment, run the command:\n\n"
+ "\tchroot %s\n\nThe system will reboot "
+ "automatically when you exit from the shell.") %
+ (anaconda.rootPath, anaconda.rootPath),
+ [_("OK")] )
rootmounted = 1
# now turn on swap
@@ -438,18 +457,24 @@ def runRescue(anaconda, instClass):
if exc in (IndexError, ValueError, SyntaxError):
raise exc, val, sys.exc_info()[2]
- ButtonChoiceWindow(screen, _("Rescue"),
- _("An error occurred trying to mount some or all of your "
- "system. Some of it may be mounted under %s.\n\n"
- "Press <return> to get a shell. The system will reboot "
- "automatically when you exit from the shell.") % (anaconda.rootPath,),
- [_("OK")] )
+ if anaconda.isKickstart:
+ log.error("An error occurred trying to mount some or all of your system")
+ else:
+ ButtonChoiceWindow(screen, _("Rescue"),
+ _("An error occurred trying to mount some or all of your "
+ "system. Some of it may be mounted under %s.\n\n"
+ "Press <return> to get a shell. The system will reboot "
+ "automatically when you exit from the shell.") % (anaconda.rootPath,),
+ [_("OK")] )
else:
- ButtonChoiceWindow(screen, _("Rescue Mode"),
- _("You don't have any Linux partitions. Press "
- "return to get a shell. The system will reboot "
- "automatically when you exit from the shell."),
- [ _("OK") ], width = 50)
+ if anaconda.isKickstart:
+ log.info("No Linux partitions found")
+ else:
+ ButtonChoiceWindow(screen, _("Rescue Mode"),
+ _("You don't have any Linux partitions. Press "
+ "return to get a shell. The system will reboot "
+ "automatically when you exit from the shell."),
+ [ _("OK") ], width = 50)
msgStr = ""
@@ -461,5 +486,11 @@ def runRescue(anaconda, instClass):
log.error("error making a resolv.conf: %s" %(e,))
msgStr = _("Your system is mounted under the %s directory.") % (anaconda.rootPath,)
- runShell(screen, msgStr)
+ # run %post if we've mounted everything
+ if anaconda.isKickstart:
+ from kickstart import runPostScripts
+ runPostScripts(anaconda)
+ else:
+ runShell(screen, msgStr)
+
sys.exit(0)