From: "Brian C. Lane" <bcl@xxxxxxxxxx> dracut runs these from the initramfs just before shutdown/reoot --- pyanaconda/constants.py | 2 ++ pyanaconda/iutil.py | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 0 deletions(-) diff --git a/pyanaconda/constants.py b/pyanaconda/constants.py index 9ceeb9b..9163d4d 100644 --- a/pyanaconda/constants.py +++ b/pyanaconda/constants.py @@ -90,3 +90,5 @@ ROOT_PATH = "/mnt/sysimage" # NOTE: this should be LANG.CODESET, e.g. en_US.UTF-8 DEFAULT_LANG = "en_US.UTF-8" + +DRACUT_SHUTDOWN_EJECT = "/run/initramfs/usr/lib/dracut/hooks/shutdown/99anaconda-eject.sh" diff --git a/pyanaconda/iutil.py b/pyanaconda/iutil.py index 0c1ca2f..e5bc265 100644 --- a/pyanaconda/iutil.py +++ b/pyanaconda/iutil.py @@ -1002,3 +1002,27 @@ def lsmod(): with open("/proc/modules") as f: lines = f.readlines() return [l.split()[0] for l in lines] + +def dracut_eject( device ): + """ + Use dracut shutdown hook to eject media after the system is shutdown. + This is needed because we are running from the squashfs.img on the media + so ejecting too early will crash the installer. + """ + if not device: + return + + try: + if not os.path.exists( DRACUT_SHUTDOWN_EJECT ): + f = open( DRACUT_SHUTDOWN_EJECT, "w" ) + f.write( "#!/bin/sh\n" ) + f.write( "# Created by Anaconda\n" ) + else: + f = open( DRACUT_SHUTDOWN_EJECT, "a" ) + + f.write( "eject %s\n" % (device,) ) + f.close() + os.chmod( DRACUT_SHUTDOWN_EJECT, 0755 ) + log.info( "Wrote dracut shutdown eject hook for %s" % (device,) ) + except Exception, e: + log.error( "Error writing dracut shutdown eject hook for %s: %s" % (device, e) ) -- 1.7.7.6 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list