aboutsummaryrefslogtreecommitdiffstats
path: root/dfly-update
diff options
context:
space:
mode:
authorAaron LI <aly@aaronly.me>2018-03-10 20:43:06 +0800
committerAaron LI <aly@aaronly.me>2018-03-10 20:43:06 +0800
commitbd0ded70b8cea608666b25c8a00b463ca63d9b0a (patch)
treedc9983fcfa0f8e298a2fe08df1112229306a9b03 /dfly-update
parent169c3247525e9a448fd1f87c2139577fe02acb72 (diff)
downloaddfly-update-bd0ded70b8cea608666b25c8a00b463ca63d9b0a.tar.bz2
Implement the mount command
Diffstat (limited to 'dfly-update')
-rwxr-xr-xdfly-update44
1 files changed, 44 insertions, 0 deletions
diff --git a/dfly-update b/dfly-update
index 561adc0..cf5bae7 100755
--- a/dfly-update
+++ b/dfly-update
@@ -26,6 +26,7 @@ EC_TMPFILE=11
EC_MD5=12
EC_ARGS=13
EC_FETCH=14
+EC_MOUNT=15
#
@@ -45,6 +46,8 @@ UPDATE_BRANCH=
# Temporary directory to cache the image, etc, ...
CACHE_DIR="/var/tmp/${NAME}"
+# Directory to mount the system image
+MNT_DIR="/mnt/${NAME}"
#
# Helper Functions
@@ -250,6 +253,23 @@ download_image() {
|| exit ${EC_FETCH}
}
+# Mount the downloaded image (IMG file)
+#
+# mount_image(imgfile, mntpnt)
+#
+mount_image() {
+ [ $# -eq 2 ] || exit ${EC_ARGS}
+ local imgfile="$1"
+ local mntpnt="$2"
+ local vn=$(vnconfig -l | fgrep "not in use" | head -n 1 | cut -d':' -f 1)
+ [ ! -d "${mntpnt}" ] && mkdir -v "${mntpnt}"
+ echo "Mounting image ${imgfile} to ${mntpnt} ..."
+ vnconfig -v -c ${vn} ${imgfile} || exit ${EC_VN}
+ mount -r /dev/${vn}s2a ${mntpnt} \
+ && echo "DONE" \
+ || exit ${EC_MOUNT}
+}
+
}
@@ -278,6 +298,8 @@ Usage:
Show local installed system version and remote available version.
download <filename> <md5>
Download the given image and check aginst the given MD5
+ mount <filepath>
+ Mount the given image file
_EOF_
echo
cmd_version
@@ -335,6 +357,24 @@ cmd_download() {
fi
}
+# Mount the given image file
+#
+# usage:
+# cmd_mount <filepath>
+cmd_mount() {
+ [ $# -eq 1 ] || exit ${EC_ARGS}
+ local filepath="$1"
+ case "${filepath}" in
+ *.bz2)
+ echo -n "Decompressing file: ${filepath} ..."
+ bunzip2 "${filepath}"
+ echo "DONE"
+ filepath="${filepath%.bz2}"
+ ;;
+ esac
+ mount_image "${filepath}" "${MNT_DIR}"
+}
+
#
# Main
@@ -357,6 +397,10 @@ case "${COMMAND}" in
shift
cmd_download "$@"
;;
+ mount)
+ shift
+ cmd_mount "$@"
+ ;;
help|--help|-h|*)
cmd_usage
;;