4 # Required-Start: $syslog
5 # Required-Stop: $syslog
6 # Should-Start: $local_fs
7 # Should-Stop: $local_fs
8 # Default-Start: 1 2 3 4 5
10 # Short-Description: Casper init script
11 # Description: Does the proper shutdown in a casper booted system.
14 # Author: Tollef Fog Heen <tfheen@canonical.com>
15 # Marco Amadori <marco.amadori@gmail.com>
17 PATH=/usr/sbin:/usr/bin:/sbin:/bin
19 SCRIPTNAME=/etc/init.d/$NAME
21 # Exit if system was not booted by casper
22 grep -qs boot=casper /proc/cmdline || exit 0
24 # Read configuration variable file if it is present
25 [ -r /etc/$NAME.conf ] && . /etc/$NAME.conf
27 # Load the VERBOSE setting and other rcS variables
28 [ -f /etc/default/rcS ] && . /etc/default/rcS
30 # Define LSB log_* functions.
31 # Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
32 . /lib/lsb/init-functions
34 # Try to cache everything we're likely to need after ejecting. This
35 # is fragile and simple-minded, but our options are limited.
39 if [ -d "$path" ]; then
40 find "$path" -type f | xargs cat > /dev/null 2>&1
41 elif [ -f "$path" ]; then
42 if [ -x "$path" ]; then
43 if file "$path" | grep -q 'dynamically linked'; then
44 for lib in $(ldd "$path" | awk '{ print $3 }'); do
49 cat "$path" >/dev/null 2>&1
56 if [ ! -z "${NETBOOT}" ] || grep -qs netboot /proc/cmdline || grep -qsi root=/dev/nfs /proc/cmdline || grep -qsi root=/dev/cifs /proc/cmdline ; then
60 for path in $(which halt) $(which reboot) /etc/rc?.d /etc/default; do
64 eject -p -m /live_media >/dev/null 2>&1
67 echo "Please remove the disc and close the tray (if any) then press ENTER: "
68 if [ -x /sbin/usplash_write ]; then
69 /sbin/usplash_write "TIMEOUT 86400"
70 /sbin/usplash_write "TEXT-URGENT Please remove the disc, close the tray (if any)"
71 /sbin/usplash_write "TEXT-URGENT and press ENTER to continue"
78 start|restart|reload|force-reload|status)
79 [ "$VERBOSE" != no ] && log_end_msg 0
82 log_begin_msg "Caching reboot files..."
85 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
86 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
90 log_success_msg "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2