Print proper paths to user when using a absolute BOX path.

This commit is contained in:
Jakob Aarøe Dam
2015-02-19 08:58:49 +01:00
parent a1c3ffafb8
commit d84efc301a

View File

@@ -25,6 +25,12 @@ rebase(){
[[ "$?" -ne 0 ]] && error "Error during rebase" [[ "$?" -ne 0 ]] && error "Error during rebase"
} }
# Is absolute path
isabspath(){
local path=${1}
[[ $path =~ ^/.* ]]
}
if [ -z "$1" ]; then if [ -z "$1" ]; then
usage usage
exit 1 exit 1
@@ -42,7 +48,7 @@ if [[ -z "$2" ]]; then
BOX=$BOX_NAME.box BOX=$BOX_NAME.box
else else
BOX="$2" BOX="$2"
BOX_NAME=${BOX%.*} BOX_NAME=$(basename ${BOX%.*})
fi fi
[[ -f "$BOX" ]] && error "'$BOX': Already exists" [[ -f "$BOX" ]] && error "'$BOX': Already exists"
@@ -94,8 +100,12 @@ EOF
echo "==> Creating box, tarring and gzipping" echo "==> Creating box, tarring and gzipping"
tar cvzf $BOX --totals ./metadata.json ./Vagrantfile ./box.img tar cvzf $BOX --totals ./metadata.json ./Vagrantfile ./box.img
mv $BOX $CWD
echo "==> ${CWD}/${BOX} created" # if box is in tmpdir move it to CWD before removing tmpdir
if ! isabspath $BOX; then
mv $BOX $CWD
fi
echo "==> ${BOX} created"
echo "==> You can now add the box:" echo "==> You can now add the box:"
echo "==> 'vagrant box add ${BOX} --name ${BOX_NAME}'" echo "==> 'vagrant box add ${BOX} --name ${BOX_NAME}'"