summaryrefslogtreecommitdiffstats
path: root/release
diff options
context:
space:
mode:
authorgjb <gjb@FreeBSD.org>2017-07-06 04:03:21 +0000
committergjb <gjb@FreeBSD.org>2017-07-06 04:03:21 +0000
commitecdacb11285baa1a2aef943a874c5679230c0b4d (patch)
tree2f26d1395041ee54ae8ecec9811e5d794f3cec1e /release
parent54bfe395ec1166bb3db8eee35e64d6774f1b664a (diff)
downloadFreeBSD-src-ecdacb11285baa1a2aef943a874c5679230c0b4d.zip
FreeBSD-src-ecdacb11285baa1a2aef943a874c5679230c0b4d.tar.gz
MFS11 r320697:
MFC r320599: 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. Approved by: re (kib) Sponsored by: The FreeBSD Foundation
Diffstat (limited to 'release')
-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 cf8b282..f7c40b4 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
}
OpenPOWER on IntegriCloud