aboutsummaryrefslogtreecommitdiff
path: root/release/scripts
diff options
context:
space:
mode:
authorGlen Barber <gjb@FreeBSD.org>2017-07-03 14:31:38 +0000
committerGlen Barber <gjb@FreeBSD.org>2017-07-03 14:31:38 +0000
commit5567474c4a6551e911009e6eb80bf599bc20ae2c (patch)
treef0dd8b6e69f36655de62305289799dcaf1b23278 /release/scripts
parenta0c59c7afd048327c8a5c79dd2542eb7c85d00ec (diff)
downloadsrc-5567474c4a6551e911009e6eb80bf599bc20ae2c.tar.gz
src-5567474c4a6551e911009e6eb80bf599bc20ae2c.zip
Fix Vagrant image upload after recent API changes.
- Update ATLAS_UPLOAD_URL to avoid various regular expressions from failing to match due to redirections. - Use ATLAS_UPLOAD_URL throughout the script. - Adjust several regular expression patterns. MFC after: 3 days Sponsored by: The FreeBSD Foundation
Notes
Notes: svn path=/head/; revision=320599
Diffstat (limited to 'release/scripts')
-rwxr-xr-xrelease/scripts/atlas-upload.sh38
1 files changed, 19 insertions, 19 deletions
diff --git a/release/scripts/atlas-upload.sh b/release/scripts/atlas-upload.sh
index cf8b282bd690..f7c40b463f67 100755
--- a/release/scripts/atlas-upload.sh
+++ b/release/scripts/atlas-upload.sh
@@ -27,7 +27,7 @@
#
ATLAS_API_URL=''
-ATLAS_UPLOAD_URL='https://binstore.hashicorp.com'
+ATLAS_UPLOAD_URL='https://app.vagrantup.com'
DESCRIPTION="FreeBSD Snapshot Build"
usage() {
@@ -76,7 +76,7 @@ main () {
fi
# Check to see if the box exists or create it
- BOXRESULT=$(/usr/local/bin/curl -s "https://atlas.hashicorp.com/api/v1/box/${USERNAME}/${BOX}?access_token=${KEY}")
+ BOXRESULT=$(/usr/local/bin/curl -s "${ATLAS_UPLOAD_URL}/api/v1/box/${USERNAME}/${BOX}?access_token=${KEY}")
if [ $? != 0 ]; then
echo "Failed to connect to the API"
exit 2;
@@ -84,26 +84,26 @@ main () {
echo $BOXRESULT | grep "\"name\":\"${BOX}\"" > /dev/null
if [ $? != 0 ]; then
echo "Creating box: ${BOX}"
- /usr/local/bin/curl -s https://atlas.hashicorp.com/api/v1/boxes -X POST -d "box[name]=${BOX}" -d "access_token=${KEY}" > /dev/null
- /usr/local/bin/curl -s https://atlas.hashicorp.com/api/v1/box/${USERNAME}/${BOX} -X PUT -d "box[is_private]=false" -d "access_token=${KEY}" > /dev/null
- /usr/local/bin/curl -s https://atlas.hashicorp.com/api/v1/box/${USERNAME}/${BOX} -X PUT -d "box[description]='${DESCRIPTION}'" -d "access_token=${KEY}" > /dev/null
+ /usr/local/bin/curl -s ${ATLAS_UPLOAD_URL}/api/v1/boxes -X POST -d "box[name]=${BOX}" -d "access_token=${KEY}" > /dev/null
+ /usr/local/bin/curl -s ${ATLAS_UPLOAD_URL}/api/v1/box/${USERNAME}/${BOX} -X PUT -d "box[is_private]=false" -d "access_token=${KEY}" > /dev/null
+ /usr/local/bin/curl -s ${ATLAS_UPLOAD_URL}/api/v1/box/${USERNAME}/${BOX} -X PUT -d "box[description]='${DESCRIPTION}'" -d "access_token=${KEY}" > /dev/null
else
echo "Box already exists"
fi
# Check to see if the version exists or create it
- VERSIONRESULT=$(/usr/local/bin/curl -s "https://atlas.hashicorp.com/api/v1/box/${USERNAME}/${BOX}/version/${VERSION}?access_token=${KEY}")
+ VERSIONRESULT=$(/usr/local/bin/curl -s "${ATLAS_UPLOAD_URL}/api/v1/box/${USERNAME}/${BOX}/version/${VERSION}?access_token=${KEY}")
if [ $? != 0 ]; then
echo "Failed to connect to the API"
exit 2;
fi
- echo $VERSIONRESULT | grep "\"version\":\"${VERSION}\"" > /dev/null
+ echo $VERSIONRESULT | grep "version/${VERSION}" > /dev/null
if [ $? != 0 ]; then
echo "Creating version: ${VERSION}"
- /usr/local/bin/curl -s https://atlas.hashicorp.com/api/v1/box/${USERNAME}/${BOX}/versions -X POST -d "version[version]=${VERSION}" -d "access_token=${KEY}" > /dev/null
- /usr/local/bin/curl -s https://atlas.hashicorp.com/api/v1/box/${USERNAME}/${BOX}/version/${VERSION} -X PUT -d "version[description]=${DESCRIPTION}" -d "access_token=${KEY}" > /dev/null
- VERSIONRESULT=$(/usr/local/bin/curl -s "https://atlas.hashicorp.com/api/v1/box/${USERNAME}/${BOX}/version/${VERSION}?access_token=${KEY}")
- echo $VERSIONRESULT | grep "\"version\":\"${VERSION}\"" > /dev/null
+ /usr/local/bin/curl -s ${ATLAS_UPLOAD_URL}/api/v1/box/${USERNAME}/${BOX}/versions -X POST -d "version[version]=${VERSION}" -d "access_token=${KEY}" > /dev/null
+ /usr/local/bin/curl -s ${ATLAS_UPLOAD_URL}/api/v1/box/${USERNAME}/${BOX}/version/${VERSION} -X PUT -d "version[description]=${DESCRIPTION}" -d "access_token=${KEY}" > /dev/null
+ VERSIONRESULT=$(/usr/local/bin/curl -s "${ATLAS_UPLOAD_URL}/api/v1/box/${USERNAME}/${BOX}/version/${VERSION}?access_token=${KEY}")
+ echo $VERSIONRESULT | grep "version/${VERSION}" > /dev/null
if [ $? != 0 ]; then
echo "Failed to create version"
exit 2
@@ -113,37 +113,37 @@ main () {
fi
# Check to see if the provider exists or create it
- PROVIDERRESULT=$(/usr/local/bin/curl -s "https://atlas.hashicorp.com/api/v1/box/${USERNAME}/${BOX}/version/${VERSION}/provider/${PROVIDER}?access_token=${KEY}")
+ PROVIDERRESULT=$(/usr/local/bin/curl -s "${ATLAS_UPLOAD_URL}/api/v1/box/${USERNAME}/${BOX}/version/${VERSION}/provider/${PROVIDER}?access_token=${KEY}")
if [ $? != 0 ]; then
echo "Failed to connect to the API"
exit 2;
fi
- echo $PROVIDERRESULT | grep "\"name\":\"${PROVIDER}\"" > /dev/null
+ echo $PROVIDERRESULT | grep "provider/${PROVIDER}" > /dev/null
if [ $? != 0 ]; then
echo "Creating provider: ${PROVIDER}"
- /usr/local/bin/curl -s https://atlas.hashicorp.com/api/v1/box/${USERNAME}/${BOX}/version/${VERSION}/providers -X POST -d "provider[name]=${PROVIDER}" -d "access_token=${KEY}" > /dev/null
+ /usr/local/bin/curl -s ${ATLAS_UPLOAD_URL}/api/v1/box/${USERNAME}/${BOX}/version/${VERSION}/providers -X POST -d "provider[name]=${PROVIDER}" -d "access_token=${KEY}" > /dev/null
else
echo "Provider already exists"
fi
# Request an upload token
- TOKENRESULT=$(/usr/local/bin/curl -s "https://atlas.hashicorp.com/api/v1/box/${USERNAME}/${BOX}/version/${VERSION}/provider/${PROVIDER}/upload?access_token=${KEY}")
+ TOKENRESULT=$(/usr/local/bin/curl -s "${ATLAS_UPLOAD_URL}/api/v1/box/${USERNAME}/${BOX}/version/${VERSION}/provider/${PROVIDER}/upload?access_token=${KEY}")
if [ $? != 0 ]; then
echo "Failed to get the token from the API"
exit 2;
fi
- echo ${TOKENRESULT} | grep -E "\"(token|upload_path)\":" > /dev/null
+ echo ${TOKENRESULT} | grep -E "upload_path" > /dev/null
if [ $? != 0 ]; then
echo "No token found from the API"
exit 2
else
TOKEN=$(echo $TOKENRESULT | sed -e 's/.*token":"//' -e 's/.*upload_path":"//' -e 's/}$//g' -e 's/"//g')
echo "Uploading to Atlas"
- UPLOADRESULT=$(/usr/local/bin/curl -s -X PUT --upload-file ${FILE} ${TOKEN})
+ UPLOADRESULT=$(/usr/local/bin/curl -s -X PUT --upload-file ${FILE} "${TOKEN}")
# Validate the Upload
echo "Validating"
- VALIDRESULT=$(/usr/local/bin/curl -s "https://atlas.hashicorp.com/api/v1/box/${USERNAME}/${BOX}/version/${VERSION}/provider/${PROVIDER}?access_token=${KEY}")
+ VALIDRESULT=$(/usr/local/bin/curl -s "${ATLAS_UPLOAD_URL}/api/v1/box/${USERNAME}/${BOX}/version/${VERSION}/provider/${PROVIDER}?access_token=${KEY}")
HOSTED_TOKEN=$(echo $VALIDRESULT | sed -e 's/.*"hosted"://' -e 's/,.*$//')
if [ ! -z ${TOKEN} -a "${HOSTED_TOKEN}" != "true" ]; then
echo "Upload failed, try again."
@@ -152,7 +152,7 @@ main () {
# Release the version
echo "Releasing ${VERSION} of ${BOX} in Atlas"
- /usr/local/bin/curl -s https://atlas.hashicorp.com/api/v1/box/${USERNAME}/${BOX}/version/${VERSION}/release -X PUT -d "access_token=${KEY}" > /dev/null
+ /usr/local/bin/curl -s ${ATLAS_UPLOAD_URL}/api/v1/box/${USERNAME}/${BOX}/version/${VERSION}/release -X PUT -d "access_token=${KEY}" > /dev/null
fi
}