From 46cf7f52515f3c0dd412f94118839082d24fde53 Mon Sep 17 00:00:00 2001
From: James Meyer <james.meyer@operamail.com>
Date: Thu, 4 Dec 2008 15:19:55 -0600
Subject: Don't eject the cd if VMWARE is used or if the boot device is not a
 CD drive. Also introduce a 10 second timer before retracting the CD. REF
 FS#30

---
 abs/core-testing/linhes-live/PKGBUILD             |  2 +-
 abs/core-testing/linhes-live/etc/live-shutdown    | 45 +++++++++++++++++++----
 abs/core-testing/linhes-live/etc/rc.shutdown-live |  2 +-
 3 files changed, 40 insertions(+), 9 deletions(-)

diff --git a/abs/core-testing/linhes-live/PKGBUILD b/abs/core-testing/linhes-live/PKGBUILD
index 2052781..158d141 100644
--- a/abs/core-testing/linhes-live/PKGBUILD
+++ b/abs/core-testing/linhes-live/PKGBUILD
@@ -2,7 +2,7 @@
 # 2008.09.25
 pkgname=linhes-live
 pkgver=5.3.3
-pkgrel=6
+pkgrel=11
 
 pkgdesc="LinHes compulsory components for the Live System."
 url="http://KnoppMyth.net"
diff --git a/abs/core-testing/linhes-live/etc/live-shutdown b/abs/core-testing/linhes-live/etc/live-shutdown
index 459d4f2..3df4802 100644
--- a/abs/core-testing/linhes-live/etc/live-shutdown
+++ b/abs/core-testing/linhes-live/etc/live-shutdown
@@ -37,13 +37,44 @@ f_swapoff ()
 
 f_remountro ()
 {
-    if [ -n "${ejectdev}" ]; then
-        echo "Ejecting live CD"
-        eject ${ejectdev}
-        echo "========================================"
-        echo "It's safe to switch the computer off now"
-        echo -ne "Press Enter to continue"
-        read junk
+    bootdev=`cat /.livesys/bootdevice`
+    bootdev=`basename $bootdev`
+    for i in `ls -H /dev/cd/*`
+    do
+        cdrom=`basename $i|cut -d- -f2`
+        if [ x$cdrom = x$bootdev ]
+        then
+            ejectdev=$cdrom
+        fi
+        break
+    done
+    lspci |grep -q VMware
+    if [ !   $? = 0 ]
+    then
+        if [ -n "${ejectdev}" ]
+        then
+            echo "Ejecting CD"
+            eject ${ejectdev}
+            echo "========================================"
+            echo "Tray will retract after 10 seconds"
+            for timer in `seq -w 10 -1 0`
+            do
+                #echo -n  $timer '\x08'
+                echo -ne   "\t"$timer '\010\010\010\010'
+                sleep 1
+            done
+            echo
+            echo "========================================"
+            eject -t ${ejectdev}
+            echo
+            echo "It's safe to switch the computer off now"
+            #echo -ne "Press Enter to continue"
+            #read junk
+        else
+            echo "Boot device is not a cdrom, no need to eject"
+        fi
+    else
+        echo "VMWARE detected, not ejecting the CD"
     fi
 }
 #Preloads these commands so we can eject the CD.
diff --git a/abs/core-testing/linhes-live/etc/rc.shutdown-live b/abs/core-testing/linhes-live/etc/rc.shutdown-live
index 896bae2..79eae47 100755
--- a/abs/core-testing/linhes-live/etc/rc.shutdown-live
+++ b/abs/core-testing/linhes-live/etc/rc.shutdown-live
@@ -150,7 +150,7 @@ fi
 #F Remount / ro
 f_remountro
 #Eject the CD
-eject
+
 # Power off or reboot
 if [ "$RUNLEVEL" = "0" ]; then
     printsep
-- 
cgit v0.12