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 # Exit if the system was booted from an ISO image rather than a physical CD
28 grep -qs find_iso= /proc/cmdline && exit 0
30 # Read configuration variable file if it is present
31 [ -r /etc/live.conf ] && . /etc/live.conf
33 # Load the VERBOSE setting and other rcS variables
34 [ -f /etc/default/rcS ] && . /etc/default/rcS
36 # Define LSB log_* functions.
37 # Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
38 . /lib/lsb/init-functions
40 # Try to cache everything we're likely to need after ejecting. This
41 # is fragile and simple-minded, but our options are limited.
45 if [ -d "${path}" ]; then
46 find "${path}" -type f | xargs cat > /dev/null 2>&1
47 elif [ -f "${path}" ]; then
48 if [ -x "${path}" ]; then
49 if file "${path}" | grep -q 'dynamically linked'; then
50 for lib in $(ldd "${path}" | awk '{ print $3 }'); do
55 cat "${path}" >/dev/null 2>&1
61 if [ ! -z "${ROOTSNAP}" ]; then
62 ${DO_SNAPSHOT} --resync-string="${ROOTSNAP}"
65 if [ ! -z "${HOMESNAP}" ]; then
66 ${DO_SNAPSHOT} --resync-string="${HOMESNAP}"
70 if [ ! -z "${NETBOOT}" ] || grep -qs netboot /proc/cmdline || grep -qsi root=/dev/nfs /proc/cmdline || grep -qsi root=/dev/cifs /proc/cmdline ; then
75 if grep -qs noprompt /proc/cmdline; then
79 for path in $(which halt) $(which reboot) /etc/rc?.d /etc/default $(which stty); do
83 for x in $(cat /proc/cmdline); do
91 if [ -z ${QUICKREBOOT} ]; then
92 if [ -x /usr/bin/eject ]
94 eject -p -m /live/image >/dev/null 2>&1
96 [ "$prompt" ] || return 0
99 stty sane < /dev/console
102 echo "Please remove the disc and close the tray (if any) then press ENTER: " > /dev/console
103 if [ -x /sbin/usplash_write ]; then
104 /sbin/usplash_write "TIMEOUT 86400"
105 /sbin/usplash_write "TEXT-URGENT Please remove the disc, close the tray (if any)"
106 /sbin/usplash_write "TEXT-URGENT and press ENTER to continue"
109 read x < /dev/console
114 start|restart|reload|force-reload|status)
115 [ "${VERBOSE}" != no ] && log_end_msg 0
118 log_begin_msg "${NAME} is resyncing snapshots and caching reboot files..."
121 0|1) [ "${VERBOSE}" != no ] && log_end_msg 0 ;;
122 2) [ "${VERBOSE}" != no ] && log_end_msg 1 ;;
126 log_success_msg "Usage: ${SCRIPTNAME} {start|stop|restart|force-reload}" >&2