4 # Provides: live-initramfs
5 # Required-Start: $syslog
6 # Required-Stop: $syslog
7 # Should-Start: $local_fs
8 # Should-Stop: $local_fs
9 # Default-Start: 1 2 3 4 5
11 # Short-Description: live-initramfs init script
12 # Description: Resyncs snapshots, evantually caches files in order to
13 # let remove the media.
16 # Authors: Tollef Fog Heen <tfheen@canonical.com>
17 # Marco Amadori <marco.amadori@gmail.com>
19 PATH=/usr/sbin:/usr/bin:/sbin:/bin
21 SCRIPTNAME=/etc/init.d/${NAME}
22 DO_SNAPSHOT=/sbin/live-snapshot
24 # Exit if system was not booted by live-initramfs
25 grep -qs boot=live /proc/cmdline || exit 0
27 # Read configuration variable file if it is present
28 [ -r /etc/live.conf ] && . /etc/live.conf
30 # Load the VERBOSE setting and other rcS variables
31 [ -f /etc/default/rcS ] && . /etc/default/rcS
33 # Define LSB log_* functions.
34 # Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
35 . /lib/lsb/init-functions
37 # Try to cache everything we're likely to need after ejecting. This
38 # is fragile and simple-minded, but our options are limited.
42 if [ -d "$path" ]; then
43 find "$path" -type f | xargs cat > /dev/null 2>&1
44 elif [ -f "$path" ]; then
45 if [ -x "$path" ]; then
46 if file "$path" | grep -q 'dynamically linked'; then
47 for lib in $(ldd "$path" | awk '{ print $3 }'); do
52 cat "$path" >/dev/null 2>&1
58 if [ ! -z "${ROOTSNAP}" ]; then
59 $DO_SNAPSHOT --resync-string="${ROOTSNAP}"
62 if [ ! -z "${HOMESNAP}" ]; then
63 $DO_SNAPSHOT --resync-string="${HOMESNAP}"
67 if [ ! -z "${NETBOOT}" ] || grep -qs netboot /proc/cmdline || grep -qsi root=/dev/nfs /proc/cmdline || grep -qsi root=/dev/cifs /proc/cmdline ; then
71 for path in $(which halt) $(which reboot) /etc/rc?.d /etc/default; do
75 for x in $(cat /proc/cmdline); do
83 if [ -z ${QUICKREBOOT} ]; then
84 if [ -x /usr/bin/eject ]
86 eject -p -m /live/image >/dev/null 2>&1
90 echo "Please remove the disc and close the tray (if any) then press ENTER: "
91 if [ -x /sbin/usplash_write ]; then
92 /sbin/usplash_write "TIMEOUT 86400"
93 /sbin/usplash_write "TEXT-URGENT Please remove the disc, close the tray (if any)"
94 /sbin/usplash_write "TEXT-URGENT and press ENTER to continue"
102 start|restart|reload|force-reload|status)
103 [ "$VERBOSE" != no ] && log_end_msg 0
106 log_begin_msg "${NAME} is resyncing snapshots and caching reboot files..."
109 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
110 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
114 log_success_msg "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2