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