projects
/
live-boot-grml.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
live-snapshot: honour "-o|--output FILE".
[live-boot-grml.git]
/
bin
/
live-snapshot
diff --git
a/bin/live-snapshot
b/bin/live-snapshot
index
b5a7fa4
..
03245ea
100755
(executable)
--- a/
bin/live-snapshot
+++ b/
bin/live-snapshot
@@
-2,11
+2,11
@@
# live-snapshot - utility to manage Debian Live systems snapshots
#
# live-snapshot - utility to manage Debian Live systems snapshots
#
-# This program mount a device (fallback to /tmpfs under $MOUNTP
-# and save
the /live/cow (or a different dir) filesystem in it for reusing
+# This program mount
s
a device (fallback to /tmpfs under $MOUNTP
+# and save
s the /live/cow (or a different dir) filesystem in it for reuse
# in another live-initramfs session. Look at manpage for more info.
#
# in another live-initramfs session. Look at manpage for more info.
#
-# Copyright (C) 2006 Marco Amadori <marco.amadori@gmail.com>
+# Copyright (C) 2006
-2008
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
# Copyright (C) 2008 Chris Lamb <chris@chris-lamb.co.uk>
#
# This program is free software; you can redistribute it and/or modify
@@
-34,7
+34,6
@@
set -eu
export USERNAME USERFULLNAME HOSTNAME
PROGRAM="$(basename $0)"
export USERNAME USERFULLNAME HOSTNAME
PROGRAM="$(basename $0)"
-VERSION=0.0.2
# Needs to be available at run and reboot time
SAFE_TMPDIR="/live"
# Needs to be available at run and reboot time
SAFE_TMPDIR="/live"
@@
-43,6
+42,7
@@
SAFE_TMPDIR="/live"
MOUNTP="$(mktemp -d -p ${SAFE_TMPDIR} live-snapshot-mnt.XXXXXX)"
SNAP_COW="/live/cow"
SNAP_DEV=""
MOUNTP="$(mktemp -d -p ${SAFE_TMPDIR} live-snapshot-mnt.XXXXXX)"
SNAP_COW="/live/cow"
SNAP_DEV=""
+SNAP_OUTPUT=""
DEST="${MOUNTP}/live-sn.cpio.gz"
SNAP_TYPE="cpio"
DESKTOP_LINK="/home/${USERNAME}/Desktop/live-snapshot"
DEST="${MOUNTP}/live-sn.cpio.gz"
SNAP_TYPE="cpio"
DESKTOP_LINK="/home/${USERNAME}/Desktop/live-snapshot"
@@
-96,13
+96,13
@@
Usage ()
exit 0
}
exit 0
}
-
Version ()
{
Version ()
{
- echo "${PROGRAM}
, version ${VERSION}
"
+ echo "${PROGRAM}"
echo
echo "Copyright (C) 2006 Marco Amadori <marco.amadori@gmail.com>"
echo
echo "Copyright (C) 2006 Marco Amadori <marco.amadori@gmail.com>"
+ echo "Copyright (C) 2008 Chris Lamb <chris@chris-lamb.co.uk>"
echo
echo "This program is free software; you can redistribute it and/or modify"
echo "it under the terms of the GNU General Public License as published by"
echo
echo "This program is free software; you can redistribute it and/or modify"
echo "it under the terms of the GNU General Public License as published by"
@@
-126,19
+126,6
@@
Version ()
exit 0
}
exit 0
}
-Is_same_mount ()
-{
- dir1="$(Base_path ${1})"
- dir2="$(Base_path ${2})"
-
- if [ "${dir1}" = "${dir2}" ]
- then
- return 0
- else
- return 1
- fi
-}
-
Parse_args ()
{
# Parse command line
Parse_args ()
{
# Parse command line
@@
-198,7
+185,6
@@
Parse_args ()
esac
done
esac
done
-
}
Defaults ()
}
Defaults ()
@@
-208,7
+194,7
@@
Defaults ()
then
SNAP_COW=$(echo "${SNAP_RESYNC_STRING}" | cut -f1 -d ':')
SNAP_DEV=$(echo "${SNAP_RESYNC_STRING}" | cut -f2 -d ':')
then
SNAP_COW=$(echo "${SNAP_RESYNC_STRING}" | cut -f1 -d ':')
SNAP_DEV=$(echo "${SNAP_RESYNC_STRING}" | cut -f2 -d ':')
- DEST=
$(echo "${SNAP_RESYNC_STRING}" | cut -f3 -d ':')
+ DEST=
"${MOUNTP}/$(echo ${SNAP_RESYNC_STRING} | cut -f3 -d ':')"
case "${DEST}" in
*.cpio.gz)
case "${DEST}" in
*.cpio.gz)
@@
-230,8
+216,8
@@
Defaults ()
Error "unrecognized resync string"
;;
esac
Error "unrecognized resync string"
;;
esac
-
- else
+ elif [ -z "${SNAP_OUTPUT}" ]
+ then
# Set target file based on image
case "${SNAP_TYPE}" in
cpio)
# Set target file based on image
case "${SNAP_TYPE}" in
cpio)
@@
-246,15
+232,17
@@
Defaults ()
DEST="${MOUNTP}/live-sn.ext2"
;;
esac
DEST="${MOUNTP}/live-sn.ext2"
;;
esac
+ else
+ DEST="${SNAP_OUTPUT}"
fi
fi
-
}
Validate_input ()
{
}
Validate_input ()
{
- case "${SNAP_TYPE}" in
+ case "${SNAP_TYPE}" in
cpio|squashfs|jffs2|ext2|ext3)
;;
cpio|squashfs|jffs2|ext2|ext3)
;;
+
*)
Error "invalid filesystem type \"${SNAP_TYPE}\""
;;
*)
Error "invalid filesystem type \"${SNAP_TYPE}\""
;;
@@
-273,13
+261,12
@@
Validate_input ()
Mount_device ()
{
Mount_device ()
{
- mkdir -p "${MOUNTP}"
-
case "${SNAP_DEV}" in
"")
# create a temp
mount -t tmpfs -o rw tmpfs "${MOUNTP}"
;;
case "${SNAP_DEV}" in
"")
# create a temp
mount -t tmpfs -o rw tmpfs "${MOUNTP}"
;;
+
*)
if [ -b "${SNAP_DEV}" ]
then
*)
if [ -b "${SNAP_DEV}" ]
then
@@
-334,7
+321,7
@@
Main ()
Parse_args "${@}"
Defaults
Validate_input
Parse_args "${@}"
Defaults
Validate_input
- trap 'Clean' EXIT
+ trap 'Clean' EXIT
Mount_device
Do_snapshot
}
Mount_device
Do_snapshot
}