live-snapshot: cleaned and sorted used command line defaults.
[live-boot-grml.git] / bin / live-snapshot
index 7cf9bf9..7e68c59 100755 (executable)
@@ -40,12 +40,14 @@ SAFE_TMPDIR="/live"
 
 # Permits multiple runs
 MOUNTP="$(mktemp -d -p ${SAFE_TMPDIR} live-snapshot-mnt.XXXXXX)"
+DEST="${MOUNTP}/live-sn.cpio.gz"
+
+# Command line defaults and declarations
 SNAP_COW="/live/cow"
 SNAP_DEV=""
-DEST="${MOUNTP}/live-sn.cpio.gz"
-SNAP_TYPE="cpio"
-DESKTOP_LINK="/home/${USERNAME}/Desktop/live-snapshot"
+SNAP_OUTPUT=""
 SNAP_RESYNC_STRING=""
+SNAP_TYPE="cpio"
 
 Error ()
 {
@@ -215,7 +217,8 @@ Defaults ()
                                Error "unrecognized resync string"
                                ;;
                esac
-       else
+       elif [ -z "${SNAP_OUTPUT}" ]
+       then
                # Set target file based on image
                case "${SNAP_TYPE}" in
                        cpio)
@@ -230,6 +233,8 @@ Defaults ()
                                DEST="${MOUNTP}/live-sn.ext2"
                                ;;
                esac
+       else
+               DEST="${SNAP_OUTPUT}"
        fi
 }
 
@@ -303,7 +308,7 @@ Do_snapshot ()
 
 Clean ()
 {
-       if echo "${DEST}" | grep -q "${MOUNTP}"
+       if [ -z "${SNAP_RESYNC_STRING}" ] && echo "${DEST}" | grep -q "${MOUNTP}"
        then
                echo "${DEST} is present on ${MOUNTP}, therefore no automatic unmounting the latter." > /dev/null 1>&2
        else