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(-)
# 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
" )
+ f.write( "# Created by Anaconda
" )
+ else:
+ f = open( DRACUT_SHUTDOWN_EJECT, "a" )
+
+ f.write( "eject %s
" % (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@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list