Skip to content

Instantly share code, notes, and snippets.

@tyabu12
Last active November 4, 2022 07:46
Show Gist options
  • Save tyabu12/ced4e09ba42e5fd16f05fc037bd9efd0 to your computer and use it in GitHub Desktop.
Save tyabu12/ced4e09ba42e5fd16f05fc037bd9efd0 to your computer and use it in GitHub Desktop.
Vagrant cloud upload script.
#!/bin/bash
USERNAME="CHANGE ME"
PROVIDER_NAME="virtualbox"
ACCESS_TOKEN="CHANGE ME"
set -eu
if [ $# -ne 3 ]; then
cat <<_EOT_
Usage:
$0 <box_name> <version> <box_filepath>
_EOT_
exit 1
fi
BOX_NAME=$1
VERSION=$2
BOX_FILEPATH=$3
UPLOAD_PATH=`curl -s "https://vagrantcloud.com/api/v1/box/${USERNAME}/${BOX_NAME}/version/${VERSION}/provider/${PROVIDER_NAME}/upload?access_token=${ACCESS_TOKEN}" | jq -r '.upload_path'`
echo "Uploading to $UPLOAD_PATH ..."
curl -X PUT --upload-file $BOX_FILEPATH $UPLOAD_PATH
echo "done!"
@tyabu12
Copy link
Author

tyabu12 commented Aug 2, 2018

Requirements

  • bash
  • curl
  • jq

Reference

Creating a New Vagrant Box - Vagrant by HashiCorp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment