/bin/live-medium-eject is in live-tools 4.0.2-1.1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | #!/bin/sh
## live-tools(7) - System Support Scripts
## Copyright (C) 2006-2013 Daniel Baumann <mail@daniel-baumann.ch>
##
## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
## This is free software, and you are welcome to redistribute it
## under certain conditions; see COPYING for details.
set -e
# Exit if system is not a live system
if ! grep -qs "boot=live" /proc/cmdline || \
# Exit if system is netboot
grep -qs "netboot" /proc/cmdline || \
grep -qs "root=/dev/nfs" /proc/cmdline || \
grep -qs "root=/dev/cifs" /proc/cmdline || \
# Exit if system is findiso
grep -qs "find_iso" /proc/cmdline || \
# Exit if system is toram
grep -qs "toram" /proc/cmdline || \
# Exit if user disabled medium eject
grep -qs "cdrom-detect/eject=false" /proc/cmdline || \
grep -qs "noeject" /proc/cmdline
then
exit 0
fi
# Reading configuration files from filesystem and live-medium
for _FILE in /etc/live/tools.conf /etc/live/tools/* \
/lib/live/mount/medium/live/tools.conf /lib/live/mount/medium/live/tools/*
do
if [ -e "${_FILE}" ]
then
. "${_FILE}"
fi
done
# Setting defaults
LIVE_MEDIUM_EJECT_VERBOSE="${LIVE_MEDIUM_EJECT_VERBOSE:-true}"
# Ejecting live-medium
_DEVICE="$(awk '/\/lib\/live\/mount\/medium / { print $1 }' /proc/mounts) | sed -e 's|/dev/||' -e 's|[0-9].*$||')"
if [ ! -b "/dev/${_DEVICE}" ]
then
exit 0
fi
case "${_DEVICE}" in
sd*)
if readlink "/sys/block/${_DEVICE}" | grep -q usb
then
# ignoring usb mass storage devices
# (they need coldreboot to recover)
exit 0
fi
;;
esac
if [ -x "$(which eject 2> /dev/null)" ]
then
eject -p -m /dev/${_DEVICE} > /dev/null 2>&1
fi
case "${LIVE_MEDIUM_EJECT_VERBOSE}" in
true)
if [ -x /bin/plymouth ] && plymouth --ping
then
plymouth message --text="Please remove the live-medium, close the tray (if any) and press ENTER to continue:"
plymouth watch-keystroke > /dev/null
else
stty sane < /dev/console
printf "\n\nPlease remove the live-medium, close the tray (if any) and press ENTER to continue:" > /dev/console
read x < /dev/console
fi
;;
esac
|