# for reuse in another live-boot session.
# Look at the manpage for more informations.
#
-# Copyright (C) 2006-2008 Marco Amadori <marco.amadori@gmail.com>
+# Copyright (C) 2006-2010 Marco Amadori <marco.amadori@gmail.com>
# Copyright (C) 2008 Chris Lamb <chris@chris-lamb.co.uk>
#
# This program is free software: you can redistribute it and/or modify
. /usr/share/initramfs-tools/scripts/live-helpers
-LIVE_CONF="/etc/live.conf"
+LIVE_CONF="/etc/live/boot.d/snapshot.conf"
if [ -r "${LIVE_CONF}" ]
then
# Parse resync string
if [ -n "${SNAP_RESYNC_STRING}" ]
then
- SNAP_COW=$(echo "${SNAP_RESYNC_STRING}" | sed -e 's|^/root\([^:.]*\).*$|'"${DEF_SNAP_COW}"'\1|')
+ SNAP_COW=$(echo "${SNAP_RESYNC_STRING}" | sed -r -e 's#^([^:]*).*$#'"${DEF_SNAP_COW}"'\1#')
SNAP_DEV=$(echo "${SNAP_RESYNC_STRING}" | cut -f2 -d ':')
SNAP_MNT=$(echo "${SNAP_RESYNC_STRING}" | cut -f3 -d ':')
DEST="${MOUNTP}/${SNAP_MNT}"
.\" This file was generated with po4a. Translate the source file.
.\"
.\"*******************************************************************
-.TH LIVE\-BOOT 7 06.09.2010 3.0~a5 "Debian Live Projekt"
+.TH LIVE\-BOOT 7 14.09.2010 3.0~a6 "Debian Live Projekt"
.SH NAME
\fBlive\-boot\fP \- System Boot Skripte
.\" This file was generated with po4a. Translate the source file.
.\"
.\"*******************************************************************
-.TH LIVE\-BOOT 1 06.09.2010 3.0~a5 "Debian Live Projekt"
+.TH LIVE\-BOOT 1 14.09.2010 3.0~a6 "Debian Live Projekt"
.SH NAME
\fBlive\-snapshot\fP \- simple script to ease persistence usage
-.TH LIVE\-BOOT 7 2010\-09\-06 3.0~a5 "Debian Live Project"
+.TH LIVE\-BOOT 7 2010\-09\-14 3.0~a6 "Debian Live Project"
.SH NAME
\fBlive\-boot\fR \- System Boot Scripts
-.TH LIVE\-BOOT 1 2010\-09\-06 3.0~a5 "Debian Live Project"
+.TH LIVE\-BOOT 1 2010\-09\-14 3.0~a6 "Debian Live Project"
.SH NAME
\fBlive\-snapshot\fR \- simple script to ease persistence usage
#
msgid ""
msgstr ""
-"Project-Id-Version: live-boot 3.0~a5\n"
-"POT-Creation-Date: 2010-09-06 15:17+0300\n"
+"Project-Id-Version: live-boot 3.0~a6\n"
+"POT-Creation-Date: 2010-09-14 08:52+0300\n"
"PO-Revision-Date: 2010-05-24 12:34+0300\n"
"Last-Translator: Daniel Baumann <daniel@debian.org>\n"
"Language-Team: none\n"
#. type: TH
#: en/live-boot.7:1 en/live-snapshot.1:1
#, no-wrap
-msgid "2010-09-06"
-msgstr "06.09.2010"
+msgid "2010-09-14"
+msgstr "14.09.2010"
#. type: TH
#: en/live-boot.7:1 en/live-snapshot.1:1
#, no-wrap
-msgid "3.0~a5"
-msgstr "3.0~a5"
+msgid "3.0~a6"
+msgstr "3.0~a6"
#. type: TH
#: en/live-boot.7:1 en/live-snapshot.1:1
#
msgid ""
msgstr ""
-"Project-Id-Version: live-boot 3.0~a5\n"
-"POT-Creation-Date: 2010-09-06 15:17+0300\n"
+"Project-Id-Version: live-boot 3.0~a6\n"
+"POT-Creation-Date: 2010-09-14 08:52+0300\n"
"PO-Revision-Date: 2010-05-24 12:34+0300\n"
"Last-Translator: Daniel Baumann <daniel@debian.org>\n"
"Language-Team: none\n"
#. type: TH
#: en/live-boot.7:1 en/live-snapshot.1:1
#, no-wrap
-msgid "2010-09-06"
-msgstr "06.09.2010"
+msgid "2010-09-14"
+msgstr "14.09.2010"
#. type: TH
#: en/live-boot.7:1 en/live-snapshot.1:1
#, no-wrap
-msgid "3.0~a5"
-msgstr "3.0~a5"
+msgid "3.0~a6"
+msgstr "3.0~a6"
#. type: TH
#: en/live-boot.7:1 en/live-snapshot.1:1
msgid ""
msgstr ""
"Project-Id-Version: live-boot VERSION\n"
-"POT-Creation-Date: 2010-09-06 15:17+0300\n"
+"POT-Creation-Date: 2010-09-14 08:52+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
#. type: TH
#: en/live-boot.7:1 en/live-snapshot.1:1
#, no-wrap
-msgid "2010-09-06"
+msgid "2010-09-14"
msgstr ""
#. type: TH
#: en/live-boot.7:1 en/live-snapshot.1:1
#, no-wrap
-msgid "3.0~a5"
+msgid "3.0~a6"
msgstr ""
#. type: TH
msgid ""
msgstr ""
"Project-Id-Version: live-boot VERSION\n"
-"POT-Creation-Date: 2010-09-06 15:17+0300\n"
+"POT-Creation-Date: 2010-09-14 08:52+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
#. type: TH
#: en/live-boot.7:1 en/live-snapshot.1:1
#, no-wrap
-msgid "2010-09-06"
+msgid "2010-09-14"
msgstr ""
#. type: TH
#: en/live-boot.7:1 en/live-snapshot.1:1
#, no-wrap
-msgid "3.0~a5"
+msgid "3.0~a6"
msgstr ""
#. type: TH
if [ -b "${fromdev}" ]
then
+ log_success_msg "Copying snapshot ${fromdev} to ${todir}..."
+
# look for free mem
if [ -n "${HOMEMOUNTED}" -a "${snap_type}" = "HOME" ]
then
return 0
else
- return 1
-
log_warning_msg "Unable to find the snapshot ${snap_type} medium"
+ return 1
fi
}
snapdata="${1}"
snap_mount="${2}"
snap_type="${3}"
+ snap_relpath="${4}"
+
+ if [ -z "${snap_relpath}" ]
+ then
+ # root snapshot, default usage
+ snap_relpath="/"
+ else
+ # relative snapshot (actually used just for "/home" snapshots)
+ snap_mount="${2}${snap_relpath}"
+ fi
if [ -n "${snapdata}" ] && [ ! -b "${snapdata}" ]
then
cpioargs='--unconditional --make-directories'
fi
- cd "${snap_mount}" && zcat "${snapback}/${snapfile}" | $cpiopath $cpioargs --extract --preserve-modification-time --no-absolute-filenames --sparse 2>/dev/null
- RES="$?"
+ if [ -s "${snapback}/${snapfile}" ]
+ then
+ BEFOREDIR="$(pwd)"
+ cd "${snap_mount}" && zcat "${snapback}/${snapfile}" | $cpiopath $cpioargs --extract --preserve-modification-time --no-absolute-filenames --sparse 2>/dev/null
+ RES="$?"
+ cd "${BEFOREDIR}"
+ else
+ log_warning_msg "${snapback}/${snapfile} is empty, adding it for sync on reboot."
+ RES="0"
+ fi
if [ "${RES}" != "0" ]
then
if ! do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"
then
- log_warning_msg "Impossible to include the ${snap_type} Snapshot"
+ log_warning_msg "Impossible to include the ${snap_type} Snapshot (i)"
return 1
else
if [ -n "${snapfile}" ]
fi
fi
else
- log_warning_msg "Impossible to include the ${snap_type} Snapshot"
+ log_warning_msg "Impossible to include the ${snap_type} Snapshot (o)"
return 1
fi
- echo "export ${snap_type}SNAP="/cow${snap_mount#$rootmnt}":${snapdev}:${snapfile}" >> /etc/live.conf # for resync on reboot/halt
+ echo "export ${snap_type}SNAP=${snap_relpath}:${snapdev}:${snapfile}" >> snapshot.conf # for resync on reboot/halt
return 0
}
# Look for other snapshots to copy in
try_snap "${root_snapdata}" "${rootmnt}" "ROOT"
# This second type should be removed when snapshot grow smarter
- try_snap "${home_snapdata}" "${rootmnt}/home" "HOME"
+ try_snap "${home_snapdata}" "${rootmnt}" "HOME" "/home"
fi
if [ -n "${SHOWMOUNTS}" ]
# when booting FAI, this simple workaround solves it
ls /root/* >/dev/null 2>&1
+ # copy snapshot configuration if exists
+ if [ -f snapshot.conf ]
+ then
+ log_begin_msg "Copying snapshot.conf to ${rootmnt}/etc/live/boot.d"
+ if [ ! -d "${rootmnt}/etc/live/boot.d" ]
+ then
+ mkdir -p "${rootmnt}/etc/live/boot.d"
+ fi
+ cp snapshot.conf "${rootmnt}/etc/live/boot.d/"
+ log_end_msg
+ fi
+
maybe_break live-bottom
log_begin_msg "Running /scripts/live-bottom\n"