[PATCH 3/4] When anaconda halts, return a code so init knows what to do (#525615).

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Also, do the appropriate shutdown/halt/reboot kickstart action at the end of
anaconda as well.
---
 anaconda |   31 ++++++++++++++++++++++---------
 1 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/anaconda b/anaconda
index 55eaf8d..f404f14 100755
--- a/anaconda
+++ b/anaconda
@@ -1066,19 +1066,32 @@ if __name__ == "__main__":
     else:
         kickstart.setSteps(anaconda)
 
+    rc = 0
+
     try:
         anaconda.intf.run(anaconda)
     except SystemExit, code:
-        anaconda.intf.shutdown()
-
-    if anaconda.isKickstart and anaconda.id.ksdata.reboot.eject:
-        for drive in anaconda.id.storage.devicetree.devices.values():
-            if drive.type != "cdrom":
-                continue
-
-            log.info("attempting to eject %s" % drive.path)
-            drive.eject()
+        rc = code
 
+    anaconda.intf.shutdown()
     del anaconda.intf
 
+    if anaconda.isKickstart:
+        from pykickstart.constants import KS_HALT, KS_POWEROFF
+
+        if anaconda.id.ksdata.reboot.eject:
+            for drive in anaconda.id.storage.devicetree.getDevicesByType("cdrom"):
+                log.info("attempting to eject %s" % drive.path)
+                drive.eject()
+
+        # Only perform these actions if anaconda properly finished up.  The
+        # default action for anaconda is to reboot, so we don't need to do
+        # that here.
+        if rc == 0 and anaconda.id.ksdata.reboot.action == KS_HALT:
+            iutil.execWithRedirect("halt", [], searchPath=1)
+        elif rc == 0 and anaconda.id.ksdata.reboot.action == KS_POWEROFF:
+            iutil.execWithRedirect("poweroff", [], searchPath=1)
+
+    sys.exit(rc)
+
 # vim:tw=78:ts=4:et:sw=4
-- 
1.6.5.1

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux