Created
April 21, 2018 08:14
-
-
Save ikemo3/afe577adc928a76a55151e90c15fae70 to your computer and use it in GitHub Desktop.
virtual machine image to tarball.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ $# -ne 3 ] | |
then | |
echo "vmimg-to-tar.sh vm-image-path path-to-write tar-out-file" | |
exit 1 | |
fi | |
IMG=$1 | |
PATH_TO_WRITE=$2 | |
TAR=$3 | |
IMG_FILE=$(basename "$IMG") | |
TAR_FILE=$(basename "$TAR") | |
IMG_DIR=$(cd "$(dirname "$IMG")" || exit; pwd) | |
TAR_DIR=$(cd "$(dirname "$TAR")" || exit; pwd) | |
docker run -it --rm \ | |
-v "$IMG_DIR":/root/in \ | |
-v "$TAR_DIR":/root/out \ | |
--entrypoint /usr/bin/virt-tar-out \ | |
curator/guestfish \ | |
-a "/root/in/$IMG_FILE" ${PATH_TO_WRITE} "/root/out/$TAR_FILE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment