tools/create_box.sh in vagrant-libvirt-0.0.26 vs tools/create_box.sh in vagrant-libvirt-0.0.27
- old
+ new
@@ -1,11 +1,11 @@
#!/usr/bin/env bash
#set -xu
error() {
local msg="${1}"
- echo "==> ${msg}"
+ echo "==> ERROR: ${msg}"
exit 1
}
usage() {
echo "Usage: ${0} IMAGE [BOX]"
@@ -68,9 +68,13 @@
echo "==> Image has backing image, copying image and rebasing ..."
trap "rm -rf $TMP_DIR" EXIT
cp "$IMG" "$TMP_IMG"
rebase "$TMP_IMG"
else
+ if fuser -s "$IMG"; then
+ error "Image '$IMG_BASENAME' is used by another process"
+ fi
+
# move the image to get a speed-up and use less space on disk
trap 'mv "$TMP_IMG" "$IMG"; rm -rf "$TMP_DIR"' EXIT
mv "$IMG" "$TMP_IMG"
fi