Adding casper 1.61+debian-1.
[live-boot-grml.git] / debian / init.d
1 #! /bin/sh
2
3 grep -qs boot=casper /proc/cmdline || exit 0
4
5 # Try to cache everything we're likely to need after ejecting.  This
6 # is fragile and simple-minded, but our options are limited.
7 cache_path() {
8     path="$1"
9
10     if [ -d "$path" ]; then
11         find "$path" -type f | xargs cat > /dev/null 2>&1
12     elif [ -f "$path" ]; then
13         if [ -x "$path" ]; then
14             if file "$path" | grep -q 'dynamically linked'; then
15                 for lib in $(ldd "$path" | awk '{ print $3 }'); do
16                     cache_path "$lib"
17                 done
18             fi
19         fi
20         cat "$path" >/dev/null 2>&1
21     fi
22 }
23
24 for path in $(which halt) $(which reboot) /etc/rc?.d /etc/default; do
25     cache_path "$path"
26 done
27
28 eject -p -m /cdrom >/dev/null 2>&1
29
30 # XXX - i18n
31 echo -n "Please remove the disc, close the tray (if any) and press ENTER: "
32 if [ -x /sbin/usplash_write ]; then
33     /sbin/usplash_write "TIMEOUT 0"
34     /sbin/usplash_write "TEXT Please remove the disc, close the tray (if any)"
35     /sbin/usplash_write "TEXT and press ENTER to continue"
36 fi
37
38 read x < /dev/console
39
40 exit 0