diff options
author | Aaron LI <aly@aaronly.me> | 2019-01-10 09:58:17 +0800 |
---|---|---|
committer | Aaron LI <aly@aaronly.me> | 2019-01-16 22:53:01 +0800 |
commit | fcba9d41e3a27913fec69ed949a09e62ca530092 (patch) | |
tree | bb84a3dff468d8428f1b0ff247cd91a67f288d2d | |
parent | 9b9f22a7faf78882576270e1a99577e3e7828fb9 (diff) | |
download | dfly-update-fcba9d41e3a27913fec69ed949a09e62ca530092.tar.bz2 |
Better handle the argument of specifying the image file
-rwxr-xr-x | dfly-update | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/dfly-update b/dfly-update index a0827e1..f248916 100755 --- a/dfly-update +++ b/dfly-update @@ -409,8 +409,9 @@ usage() { cat <<_EOF_ Upgrade a DragonFly BSD system using a binary release/snapshot -Usage: ${0##*/} [-h] [-c <config-file>] [-d] - [-s <start-step>] [-S <stop-step] <dfly.img> +Usage: +${0##*/} [-h] [-c <config-file>] [-d] + [-s <start-step>] [-S <stop-step] {dfly.img} Options: -h : show this help @@ -430,6 +431,11 @@ Steps: 7. umount the system image 8. misc operations after upgrade +Note: +The {dfly.img} is required when <start-step> is 0 (the default), +otherwise it is assumed that the image file is already mounted +at \${MNT_DIR} (default to be '${MNT_DIR}'). + v${VERSION} ${AUTHOR} ${URL} @@ -478,14 +484,20 @@ while getopts :c:dhs:S: opt; do done shift $((OPTIND - 1)) -[ $# -ne 1 ] && { usage; exit ${EC_ARGS}; } -IMGFILE="$1" -[ -r "${IMGFILE}" ] || error ${EC_NOFILE} "file not exists: ${IMGFILE}" + +if [ ${ISTART} -eq 0 ]; then + [ $# -eq 1 ] || error ${EC_ARGS} "no image file provided" + IMG="$1" + [ -f "${IMG}" ] || error ${EC_NOFILE} "image file not exists: ${IMG}" +else + DEV=$(get_mount_dev ${MNT_DIR}) + [ -n "${DEV}" ] || error ${EC_MOUNT} "nothing mounted at: ${MNT_DIR}" +fi istep=0 -echo "[${istep}] Mounting image ${IMGFILE} to ${MNT_DIR} ..." +echo "[${istep}] Mounting image to ${MNT_DIR} ..." [ ${istep} -ge ${ISTART} -a ${istep} -le ${ISTOP} ] && - mount_image "${IMGFILE}" "${MNT_DIR}" || + mount_image "${IMG}" "${MNT_DIR}" || echo "(skipped)" istep=$((${istep} + 1)) |