FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian Kernel

 
 
LinkBack Thread Tools
 
Old 02-20-2012, 08:59 PM
"Brian C. Lane"
 
Default add dracut shutdown eject hook function (#787461)

From: "Brian C. Lane" <bcl@redhat.com>

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
" )
+ 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
 

Thread Tools




All times are GMT. The time now is 08:52 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org