3 ## live-config(7) - System Configuration Scripts
4 ## Copyright (C) 2006-2012 Daniel Baumann <daniel@debian.org>
6 ## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
7 ## This is free software, and you are welcome to redistribute it
8 ## under certain conditions; see COPYING for details.
13 # Exit if system is not a live system
14 if ! grep -qs
"boot=live" /proc
/cmdline || \
15 # Exit if system is netboot
16 grep -qs
"netboot" /proc
/cmdline || \
17 grep -qs
"root=/dev/nfs" /proc
/cmdline || \
18 grep -qs
"root=/dev/cifs" /proc
/cmdline || \
19 # Exit if system is toram
20 grep -qs
"toram" /proc
/cmdline
27 # Try to cache everything we're likely to need after ejecting. This
28 # is fragile and simple-minded, but our options are limited.
35 find "${path}" -type f |
xargs cat > /dev
/null
2>&1
38 if file -L
"${path}" |
grep -q
'dynamically linked'
40 # ldd output can be of three forms:
41 # 1. linux-vdso.so.1 => (0x00007fffe3fb4000)
42 # This is a virtual, kernel shared library and we want to skip it
43 # 2. libc.so.6 => /lib/libc.so.6 (0x00007f5e9dc0c000)
44 # We want to cache the third word.
45 # 3. /lib64/ld-linux-x86-64.so.2 (0x00007f5e9df8b000)
46 # We want to cache the first word.
47 ldd
"${path}" |
while read line
49 if echo "$line" |
grep -qs
' => '
52 elif echo "$line" |
grep -qs
' => '
54 lib
=$
(echo "${line}" |
awk '{ print $3 }')
56 lib
=$
(echo "${line}" |
awk '{ print $1 }')
62 cat "${path}" >/dev
/null
2>&1
68 # search in /proc/mounts for the device that is mounted at /lib/live/mount/medium
69 while read DEVICE MOUNT REST
71 if [ "${MOUNT}" = "/lib/live/mount/medium" ]
79 device_is_USB_flash_drive
()
81 # remove leading "/dev/" and all trailing numbers from input
82 DEVICE
=$
(expr substr
${1} 6 3)
84 # check that device starts with "sd"
85 [ "$(expr substr ${DEVICE} 1 2)" != "sd" ] && return 1
87 # check that the device is an USB device
88 if readlink
/sys
/block
/${DEVICE} |
grep -q usb
99 BOOT_DEVICE
="$(get_boot_device)"
101 if device_is_USB_flash_drive
${BOOT_DEVICE}
103 # do NOT eject USB flash drives!
104 # otherwise rebooting with most USB flash drives
105 # failes because they actually remember the
106 # "ejected" state even after reboot
107 MESSAGE
="Please remove the USB flash drive"
109 if [ "${NOPROMPT}" = "usb" ]
115 # ejecting is a very good idea here
116 MESSAGE
="Please remove the disc, close the tray (if any)"
118 if [ -x
/usr
/bin
/eject
]
120 eject
-p
-m
/lib
/live
/mount
/medium
>/dev
/null
2>&1
123 if [ "${NOPROMPT}" = "cd" ]
129 [ "$prompt" ] ||
return 0
131 if [ -x
/bin
/plymouth
] && plymouth
--ping
133 plymouth message
--text
="${MESSAGE} and press ENTER to continue:"
134 plymouth watch
-keystroke
> /dev
/null
136 stty sane
< /dev
/console
138 printf "\n\n${MESSAGE} and press ENTER to continue:" > /dev
/console
140 read x
< /dev
/console
144 echo "live-boot: caching reboot files..."
147 if [ "${NOPROMPT}" = "Yes" ]
152 for path
in $
(which halt
) $
(which reboot
) /etc
/rc?.d
/etc
/default $
(which stty
) /bin
/plymouth
157 mount
-o remount
,ro
/lib
/live
/mount
/overlay
> /dev
/null
2>&1
159 # Remounting any persistence devices read-only
160 for _MOUNT
in $
(awk '/\/lib\/live\/mount\/persistence/ { print $2 }' /proc
/mounts
)
162 mount
-o remount
,ro
${_MOUNT} > /dev
/null
2>&1
165 # Flush filesystem buffers
168 # Check if we need to eject the drive
169 if grep -qs
"cdrom-detect/eject=false" /proc
/cmdline || \
170 grep -qs
"noeject" /proc
/cmdline || \
171 grep -qs
"find_iso" /proc
/cmdline