From 4befa6caf93a078862a08abe001f80a5a608eb79 Mon Sep 17 00:00:00 2001 From: Giuliano Daddario Date: Fri, 8 Nov 2019 16:59:53 +0100 Subject: [PATCH] Add DOWNLOAD HEADER --- bin/compile | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/bin/compile b/bin/compile index 4ec2856..3b8f953 100644 --- a/bin/compile +++ b/bin/compile @@ -19,6 +19,7 @@ source "$BP_DIR/lib/stdlib.sh" downloadAgent() { local DOWNLOADURL=$1 local INSTALLERFILE=$2 + local DOWNLOADHEADER=$3 local USERAGENT='heroku/1.0' # determine ssl mode @@ -38,14 +39,15 @@ downloadAgent() { puts_error "Neither curl nor wget executable found!" exit 1 fi - + local RETRYTIMEOUT=0 local DOWNLOADERRORS=0 while [[ $DOWNLOADERRORS -lt 3 ]]; do sleep $RETRYTIMEOUT - puts_step "Downloading OneAgent installer..." - $DOWNLOADCOMMAND + puts_step "Downloading OneAgent installer from ${DOWNLOADURL}" + $DOWNLOADCOMMAND --header "$DOWNLOADHEADER" + if [[ $? != 0 ]]; then DOWNLOADERRORS=$((DOWNLOADERRORS+1)) RETRYTIMEOUT=$(($RETRYTIMEOUT+5)) @@ -85,18 +87,20 @@ mkdir -p "$BUILD_DIR/.profile.d" # Compile OneAgent Download URL DT_API_URL="${DT_API_URL:-https://$DT_TENANT.live.dynatrace.com/api}" -DT_DOWNLOAD_URL="${DT_DOWNLOAD_URL:-$DT_API_URL/v1/deployment/installer/agent/unix/paas-sh/latest?Api-Token=$DT_API_TOKEN&arch=x86}" +DT_DOWNLOAD_URL="${DT_DOWNLOAD_URL:-$DT_API_URL/v1/deployment/installer/agent/unix/paas-sh/latest?&arch=x86}" +DT_DOWNLOAD_HEADER="Authorization: Api-Token ${DT_API_TOKEN}" puts_verbose "DT_TENANT=$DT_TENANT" puts_verbose "DT_API_TOKEN=$DT_API_TOKEN" | sed "s#$DT_API_TOKEN#DEDUCTED#g" puts_verbose "DT_API_URL=$DT_API_URL" puts_verbose "DT_DOWNLOAD_URL=$DT_DOWNLOAD_URL" | sed "s#$DT_API_TOKEN#DEDUCTED#g" +puts_verbose "DT_DOWNLOAD_HEADER=${DT_DOWNLOAD_HEADER}" # Download and install the agent INSTALLER_FILE=$(mktemp) # disable errexit temporarily as error handling is done explicitly by downloadAgent set +e -downloadAgent "${DT_DOWNLOAD_URL}" "${INSTALLER_FILE}" +downloadAgent "${DT_DOWNLOAD_URL}" "${INSTALLER_FILE}" "${DT_DOWNLOAD_HEADER}" set -e puts_step "Running Dynatrace OneAgent installer..."