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: Resyncs snapshots, evantually caches files in order
12 # to let remove the media.
15 # Author: Tollef Fog Heen <tfheen@canonical.com>
16 # Marco Amadori <marco.amadori@gmail.com>
18 PATH=/usr/sbin:/usr/bin:/sbin:/bin
20 SCRIPTNAME=/etc/init.d/${NAME}
21 DO_SNAPSHOT=/sbin/${NAME}-snapshot
23 # Exit if system was not booted by casper
24 grep -qs boot=casper /proc/cmdline || exit 0
26 # Read configuration variable file if it is present
27 [ -r /etc/$NAME.conf ] && . /etc/$NAME.conf
29 # Load the VERBOSE setting and other rcS variables
30 [ -f /etc/default/rcS ] && . /etc/default/rcS
32 # Define LSB log_* functions.
33 # Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
34 . /lib/lsb/init-functions
36 # Try to cache everything we're likely to need after ejecting. This
37 # is fragile and simple-minded, but our options are limited.
41 if [ -d "$path" ]; then
42 find "$path" -type f | xargs cat > /dev/null 2>&1
43 elif [ -f "$path" ]; then
44 if [ -x "$path" ]; then
45 if file "$path" | grep -q 'dynamically linked'; then
46 for lib in $(ldd "$path" | awk '{ print $3 }'); do
51 cat "$path" >/dev/null 2>&1
57 if [ ! -z "${ROOTSNAP}" ]; then
58 $DO_SNAPSHOT --resync-string="${ROOTSNAP}"
61 if [ ! -z "${HOMESNAP}" ]; then
62 $DO_SNAPSHOT --resync-string="${HOMESNAP}"
66 if [ ! -z "${NETBOOT}" ] || grep -qs netboot /proc/cmdline || grep -qsi root=/dev/nfs /proc/cmdline || grep -qsi root=/dev/cifs /proc/cmdline ; then
70 for path in $(which halt) $(which reboot) /etc/rc?.d /etc/default; do
74 eject -p -m /live_media >/dev/null 2>&1
77 echo "Please remove the disc and close the tray (if any) then press ENTER: "
78 if [ -x /sbin/usplash_write ]; then
79 /sbin/usplash_write "TIMEOUT 86400"
80 /sbin/usplash_write "TEXT-URGENT Please remove the disc, close the tray (if any)"
81 /sbin/usplash_write "TEXT-URGENT and press ENTER to continue"
88 start|restart|reload|force-reload|status)
89 [ "$VERBOSE" != no ] && log_end_msg 0
92 log_begin_msg "${NAME} is resyncing snapshots and caching reboot files..."
95 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
96 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
100 log_success_msg "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2