tools/create_box.sh in vagrant-libvirt-0.0.36 vs tools/create_box.sh in vagrant-libvirt-0.0.37
- old
+ new
@@ -6,11 +6,11 @@
echo "==> ERROR: ${msg}"
exit 1
}
usage() {
- echo "Usage: ${0} IMAGE [BOX]"
+ echo "Usage: ${0} IMAGE [BOX] [Vagrantfile.add]"
echo
echo "Package a qcow2 image into a vagrant-libvirt reusable box"
}
# Print the image's backing file
@@ -30,11 +30,11 @@
isabspath(){
local path=${1}
[[ "$path" =~ ^/.* ]]
}
-if [ -z "$1" ]; then
+if [ -z "$1" ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
usage
exit 1
fi
IMG=$(readlink -e "$1")
@@ -60,10 +60,14 @@
mkdir -p "$TMP_DIR"
[[ ! -r "$IMG" ]] && error "'$IMG': Permission denied"
+if [ -n "$3" ] && [ -r "$3" ]; then
+ VAGRANTFILE_ADD="$(cat $3)"
+fi
+
# We move / copy (when the image has master) the image to the tempdir
# ensure that it's moved back / removed again
if [[ -n $(backing "$IMG") ]]; then
echo "==> Image has backing image, copying image and rebasing ..."
trap "rm -rf $TMP_DIR" EXIT
@@ -105,9 +109,11 @@
libvirt.host = ""
libvirt.connect_via_ssh = false
libvirt.storage_pool_name = "default"
end
+
+${VAGRANTFILE_ADD:-}
end
EOF
echo "==> Creating box, tarring and gzipping"