X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=bin%2Fcasper-snapshot;h=c0c8662135cec3cae2344555c73a89ec45b8f349;hb=beec4f9fb766be23d575b070e398639d5a4a9c9d;hp=d2cb9e8ae52699cde04064a315bb87db596fe176;hpb=112ee0e018e658f0c6dfb0bee32be19ae67ce00f;p=live-boot-grml.git diff --git a/bin/casper-snapshot b/bin/casper-snapshot index d2cb9e8..c0c8662 100644 --- a/bin/casper-snapshot +++ b/bin/casper-snapshot @@ -53,13 +53,12 @@ fi # Depend on lsb-base (>= 3.0-6) to ensure that this file is present. . /lib/lsb/init-functions -# Some defaults: -MOUNTP="/mnt/casper-snapshot" -COW="/cow" +MOUNTP="" +COW="" DEV="" -DEST="${MOUNTP}/casper-sn.cpio.gz" -TYPE="cpio" -DESKTOP_LINK=/home/$USERNAME/Desktop/casper-snapshot +DEST="" +TYPE="" +DESKTOP_LINK="" Header () { @@ -92,10 +91,10 @@ Help () echo echo "Options:" echo " -c, --cow: specifies the copy on write directory (default: /cow)." - echo " -d, --destination: specifies the output snapshot directory (default: /home/\$USERNAME/Desktop/casper-snapshot)." + echo " -d, --device: specifies the output snapshot device (default: none)." echo " -o, --output: specifies the output image file (default: $type dependent)." echo " -r, --resync-string: internally used to resync previous made snapshots." - echo " -t,--type: specifies the snapshot type between \'squashfs\', \'ext2\' or \'cpio\'.gz archive (default: cpio)" + echo " -t, --type: specifies the snapshot type between \"squashfs\", \"ext2\" or \"cpio\".gz archive (default: cpio)" echo -e "\nLook at casper-snapshot(1) man page for more information." exit 0 } @@ -166,7 +165,7 @@ Parse_args () { # Parse command line ARGS="${1}" - ARGUMENTS="`getopt --longoptions cow:,destination:,output:,type:,help,usage,version --name=${PROGRAM} --options c:d:o:t:,h,u,v --shell sh -- ${ARGS}`" + ARGUMENTS="`getopt --longoptions cow:,device:,output,resync-string:,type:,help,usage,version --name=${PROGRAM} --options c:d:o:t:r:,h,u,v --shell sh -- ${ARGS}`" if [ "${?}" != "0" ]; then echo "Terminating." >&2 @@ -209,7 +208,7 @@ Mount_device () mkdir -p "${MOUNTP}" fi - if [ -n "${dev}" ]; then + if [ -z "${dev}" ]; then # create a temp mount -t tmpfs -o rw tmpfs "${MOUNTP}" if [ ! -L /home/$USERNAME/Desktop/casper-snapshot ]; then @@ -224,19 +223,26 @@ Mount_device () Defaults () { + MOUNTP="/mnt/casper-snapshot" + COW="/cow" + DEV="" + DEST="${MOUNTP}/casper-sn.cpio.gz" + TYPE="cpio" + DESKTOP_LINK=/home/$USERNAME/Desktop/casper-snapshot + if [ -n "${SNAP_RSTRING}" ]; then COW=$(echo "${SNAP_RSTRING}" | cut -f1 -d ':') DEV=$(echo "${SNAP_RSTRING}" | cut -f2 -d ':') DEST=$(echo "${SNAP_RSTRING}" | cut -f3 -d ':') case "${DEST}" in - *.cpio.gz|*.cpz|*.gz) + *.cpio.gz) TYPE="cpio" ;; - *.squashfs|*.squ}) + *.squashfs) TYPE="squashfs" ;; "") TYPE="ext2" ;; - *.ext2|*.ext) + *.ext2) TYPE="ext2" ;; *) Usage "Unregognized String" ;; @@ -264,13 +270,13 @@ Defaults () #if Is_same_mount fi - Mount_device $DEV - DEST="${MOUNTP}/${DEST}" - # check vars if [ ! -d "${COW}" ]; then Usage "Error: ${COW} is not a directory" fi + + Mount_device $DEV + } Clean ()