Last active
October 3, 2017 12:31
-
-
Save patrickcrocker/1b84350d640f1e662b2e to your computer and use it in GitHub Desktop.
CLI download of Pivnet tile and upload to Ops Manager
This file contains 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 | |
set -e | |
export PIVNET_TOKEN=GET_FROM_PIVNET_USER_PROFILE_PAGE | |
export OPSMGR_HOST=localhost | |
echo "Local file name: " | |
read -r LOCAL_FILE_NAME_INPUT | |
export LOCAL_FILE_NAME=$LOCAL_FILE_NAME_INPUT | |
echo "Remote file URL: " | |
read -r DOWNLOAD_URL_INPUT | |
export DOWNLOAD_URL=$DOWNLOAD_URL_INPUT | |
echo "Ops Manager Username: " | |
read -r OPSMGR_USER_INPUT | |
export OPSMGR_USER=$OPSMGR_USER_INPUT | |
echo "Ops Manager Password: " | |
read -rs OPSMGR_PASS_INPUT | |
export OPSMGR_PASS=$OPSMGR_PASS_INPUT | |
echo "Downloading $LOCAL_FILE_NAME from $DOWNLOAD_URL" | |
wget -O "$LOCAL_FILE_NAME" --post-data="" --header="Authorization: Token $PIVNET_TOKEN" $DOWNLOAD_URL | |
echo "Uploading $LOCAL_FILE_NAME to $OPSMGR_HOST" | |
curl "https://${OPSMGR_HOST}/api/products" -F "product[file]=@${LOCAL_FILE_NAME}" -X POST -u ${OPSMGR_USER}:${OPSMGR_PASS} -k -# -o /dev/null | |
echo "$LOCAL_FILE_NAME finished uploading to Ops Manager" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment