/lib/live/boot-init.sh is in live-config 3.0.23-1+deb8u1.
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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | #!/bin/sh
## live-config(7) - System Configuration Scripts
## Copyright (C) 2006-2013 Daniel Baumann <daniel@debian.org>
##
## 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 toram
grep -qs "toram" /proc/cmdline
then
exit 0
fi
# Try to cache everything we're likely to need after ejecting. This
# is fragile and simple-minded, but our options are limited.
cache_path()
{
path="${1}"
if [ -d "${path}" ]
then
find "${path}" -type f | xargs cat > /dev/null 2>&1
elif [ -f "${path}" ]
then
if file -L "${path}" | grep -q 'dynamically linked'
then
# ldd output can be of three forms:
# 1. linux-vdso.so.1 => (0x00007fffe3fb4000)
# This is a virtual, kernel shared library and we want to skip it
# 2. libc.so.6 => /lib/libc.so.6 (0x00007f5e9dc0c000)
# We want to cache the third word.
# 3. /lib64/ld-linux-x86-64.so.2 (0x00007f5e9df8b000)
# We want to cache the first word.
ldd "${path}" | while read line
do
if echo "$line" | grep -qs ' => '
then
continue
elif echo "$line" | grep -qs ' => '
then
lib=$(echo "${line}" | awk '{ print $3 }')
else
lib=$(echo "${line}" | awk '{ print $1 }')
fi
cache_path "${lib}"
done
fi
cat "${path}" >/dev/null 2>&1
fi
}
get_boot_device()
{
# search in /proc/mounts for the device that is mounted at /lib/live/mount/medium
while read DEVICE MOUNT REST
do
case "${MOUNT}" in
/lib/live/mount/medium)
echo "${DEVICE}"
exit 0
;;
esac
done < /proc/mounts
}
device_is_USB_flash_drive()
{
# remove leading "/dev/" and all trailing numbers from input
DEVICE=$(expr substr ${1} 6 3)
# check that device starts with "sd"
[ "$(expr substr ${DEVICE} 1 2)" != "sd" ] && return 1
# check that the device is an USB device
if readlink /sys/block/${DEVICE} | grep -q usb
then
return 0
fi
return 1
}
Eject ()
{
# TODO: i18n
BOOT_DEVICE="$(get_boot_device)"
if device_is_USB_flash_drive ${BOOT_DEVICE}
then
# do NOT eject USB flash drives!
# otherwise rebooting with most USB flash drives
# failes because they actually remember the
# "ejected" state even after reboot
MESSAGE="Please remove the USB flash drive"
case "${NOPROMPT}" in
usb)
prompt=
;;
esac
else
# ejecting is a very good idea here
MESSAGE="Please remove the disc, close the tray (if any)"
if [ -x /usr/bin/eject ]
then
eject -p -m /lib/live/mount/medium >/dev/null 2>&1
fi
case "${NOPROMPT}" in
cd)
prompt=
;;
esac
fi
[ "$prompt" ] || return 0
if [ -x /bin/plymouth ] && plymouth --ping
then
plymouth message --text="${MESSAGE} and press ENTER to continue:"
plymouth watch-keystroke > /dev/null
else
stty sane < /dev/console
printf "\n\n${MESSAGE} and press ENTER to continue:" > /dev/console
read x < /dev/console
fi
}
echo "live-boot: caching reboot files..."
prompt=1
case "${NOPROMPT}" in
yes)
prompt=
;;
esac
for path in $(which halt) $(which reboot) /etc/rc?.d /etc/default $(which stty) /bin/plymouth
do
cache_path "${path}"
done
mount -o remount,ro /lib/live/mount/overlay > /dev/null 2>&1
# Remounting any persistence devices read-only
for _MOUNT in $(awk '/\/lib\/live\/mount\/persistence/ { print $2 }' /proc/mounts)
do
mount -o remount,ro ${_MOUNT} > /dev/null 2>&1
done
# Flush filesystem buffers
sync
# Check if we need to eject the drive
if grep -qs "cdrom-detect/eject=false" /proc/cmdline || \
grep -qs "noeject" /proc/cmdline || \
grep -qs "find_iso" /proc/cmdline
then
return
else
Eject
fi
|