From 022a985b6e5a9d62ea4d0e1b9e77257124bd1f73 Mon Sep 17 00:00:00 2001 From: Tomas M Date: Fri, 9 Nov 2012 11:05:42 -0600 Subject: [PATCH] eject static binary and support --- TODO | 4 ++-- initramfs/cleanup | 26 ++++++++++++++++++++------ initramfs/static/update | 1 + 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/TODO b/TODO index 4b73c55..4a10f9e 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,4 @@ * copy DOC/* to Live Kit created * describe meaning of special files in bundles - -* bootinst.sh - if extlinux is not found, echo error msg. \ No newline at end of file +* support from=slax.iso +* noatime mount option for aufs? diff --git a/initramfs/cleanup b/initramfs/cleanup index 18e66fb..9a853cd 100644 --- a/initramfs/cleanup +++ b/initramfs/cleanup @@ -78,19 +78,32 @@ if [ "$1" = "--init" ]; then # then free up loop mounts, backwards tac /proc/mounts | grep loop | cut -d " " -f 2 | while read LINE; do - umount $LINE >/dev/console 2>&1 + umount $LINE >/dev/console 2>&1 || \ umount -l $LINE done - # and free up memory mounts, backwards + # remember from which device we are started, do it now before we lose it + DEVICE="$(cat /proc/mounts | grep /memory/data | grep /dev/ | cut -d " " -f 1)" + + # free up memory mounts, backwards tac /proc/mounts | grep memory | cut -d " " -f 2 | while read LINE; do umount $LINE >/dev/console 2>&1 - umount -l $LINE + if [ $? -ne 0 ]; then + mount -o remount,ro $LINE >/dev/console 2>&1 + umount -l $LINE + fi done - # make sure the data directory is at least remounted read-only, - # if the previous unmount failed due to some busy err - mount -o remount,ro /memory/data >/dev/console 2>/dev/null + # eject cdrom device if we were running from it + for i in $(cat /proc/sys/dev/cdrom/info | grep name); do + if [ "$DEVICE" = "/dev/$i" ]; then + echo "Attemptiong to eject /dev/$i..." >/dev/console + eject /dev/$i + echo "CD/DVD tray will close in 6 seconds..." >/dev/console + sleep 6 + eject -t /dev/$i + fi + done # and finally, last chance to run some commands by hand if grep -q debug /proc/cmdline; then @@ -98,6 +111,7 @@ if [ "$1" = "--init" ]; then setsid sh -c 'exec sh < /dev/tty1 >/dev/tty1 2>&1' fi + cat /lib/command >/dev/console $(cat /lib/command 2>/dev/null) reboot -f fi diff --git a/initramfs/static/update b/initramfs/static/update index 15e654a..90d74ae 100755 --- a/initramfs/static/update +++ b/initramfs/static/update @@ -26,3 +26,4 @@ fi ln -f busybox-$MYARCH ./busybox ln -f mount.ntfs-3g-$MYARCH ./mount.ntfs-3g ln -f mount.dynfilefs-$MYARCH ./mount.dynfilefs +ln -f eject-$MYARCH ./eject