diff options
Diffstat (limited to 'debian/casper.init')
| -rw-r--r-- | debian/casper.init | 93 |
1 files changed, 58 insertions, 35 deletions
diff --git a/debian/casper.init b/debian/casper.init index ae1a1a4..d6ec097 100644 --- a/debian/casper.init +++ b/debian/casper.init @@ -50,45 +50,68 @@ cache_path() { fi } +do_sync () +{ + # copy the tmp media on the snapshot media + fromdir="${1}" + todev="${2}" + tmnt="/mnt/temp_snap" + + mkdir "${tmnt}" && \ + mount "${todev}" "${tmnt}" -o rw && \ + cd "${fromdir}" && \ + find . -print0 | cpio -pumd0 "${tmnt}" && \ + umount "${tmnt}" && \ + rmdir "${tmnt}" +} + do_stop () { - # check for netboot - if [ ! -z "${NETBOOT}" ] || grep -qs netboot /proc/cmdline || grep -qsi root=/dev/nfs /proc/cmdline || grep -qsi root=/dev/cifs /proc/cmdline ; then - return 0 - fi - - for path in $(which halt) $(which reboot) /etc/rc?.d /etc/default; do - cache_path "$path" - done - - eject -p -m /live_media >/dev/null 2>&1 - - # XXX - i18n - echo "Please remove the disc and close the tray (if any) then press ENTER: " - if [ -x /sbin/usplash_write ]; then - /sbin/usplash_write "TIMEOUT 86400" - /sbin/usplash_write "TEXT-URGENT Please remove the disc, close the tray (if any)" - /sbin/usplash_write "TEXT-URGENT and press ENTER to continue" - fi - - read x < /dev/console + # check for netboot + if [ ! -z "${NETBOOT}" ] || grep -qs netboot /proc/cmdline || grep -qsi root=/dev/nfs /proc/cmdline || grep -qsi root=/dev/cifs /proc/cmdline ; then + return 0 + fi + + if [ ! -z "${ROOTSNAP}" ]; then + do_sync "/cow" "${ROOTSNAP}" + fi + + if [ ! -z "${HOMESNAP}" ]; then + do_sync "/home" "${HOMESNAP}" + fi + + for path in $(which halt) $(which reboot) /etc/rc?.d /etc/default; do + cache_path "$path" + done + + eject -p -m /live_media >/dev/null 2>&1 + + # XXX - i18n + echo "Please remove the disc and close the tray (if any) then press ENTER: " + if [ -x /sbin/usplash_write ]; then + /sbin/usplash_write "TIMEOUT 86400" + /sbin/usplash_write "TEXT-URGENT Please remove the disc, close the tray (if any)" + /sbin/usplash_write "TEXT-URGENT and press ENTER to continue" + fi + + read x < /dev/console } case "$1" in - start|restart|reload|force-reload|status) - [ "$VERBOSE" != no ] && log_end_msg 0 - ;; - stop) - log_begin_msg "Caching reboot files..." - do_stop - case "$?" in - 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; - 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; - esac - ;; - *) - log_success_msg "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 - exit 3 - ;; + start|restart|reload|force-reload|status) + [ "$VERBOSE" != no ] && log_end_msg 0 + ;; + stop) + log_begin_msg "Caching reboot files..." + do_stop + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + *) + log_success_msg "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 + exit 3 + ;; esac |
