Skip to content

Commit

Permalink
Merge pull request #16 from gidad/master
Browse files Browse the repository at this point in the history
Add DOWNLOAD HEADER
  • Loading branch information
gidad authored Nov 19, 2019
2 parents 37dddfd + 4befa6c commit 9c0bf32
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions bin/compile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))
Expand Down Expand Up @@ -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..."
Expand Down

0 comments on commit 9c0bf32

Please sign in to comment.