Last active
August 4, 2017 01:46
-
-
Save sturadnidge/f3e17bd9a89c800655421acbb805fe57 to your computer and use it in GitHub Desktop.
Upload File to Ops Manager
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# uaac is an alias set in .profile of ops manager user | |
shopt -s expand_aliases | |
source ~/.profile | |
function usage { | |
printf "Usage: ${0##*/} <file-to-upload.pivotal>\n" | |
exit 1 | |
} | |
if [ $# -eq 0 ] | |
then | |
usage | |
fi | |
UAA_ACCESS_TOKEN=$(uaac context | awk -F access_token: '{print $2}' | tr -d '\n' | tr -d '[[:space:]]') | |
curl -k "https://localhost/api/v0/available_products" -X POST -H "Authorization: Bearer ${UAA_ACCESS_TOKEN}" -F "product[file]=@$1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
First, get an access token:
Then, export the access token (only) as
UAA_ACCESS_TOKEN
export UAA_ACCESS_TOKEN=$(uaac context | awk -F access_token: '{print $2}' | tr -d '\n' | tr -d '[[:space:]]')