Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bash API-download script downloading ARM packages on non-ARM hosts #186

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions Agent-Install-Examples/bash/API-download/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,20 @@ cs_sensor_download() {
die "No sensor found for with OS Name: $cs_os_name"
fi

INDEX=1
INDEX=0
if [ -n "$cs_os_version" ]; then
found=0
IFS='
'
for l in $(echo "$existing_installers" | json_value "os_version"); do
INDEX=$((INDEX+1))
l=$(echo "$l" | sed 's/ *$//g' | sed 's/^ *//g')

# arm64 installers have "arm64" suffix
if [ "$cs_os_architecture" != "arm64" ] && [ -z "${l##*arm64}" ]; then
continue
fi

if echo "$l" | grep -q '/'; then
# Sensor for Ubuntu has l="14/16/18/20"
for v in $(echo "$l" | tr '/' '\n'); do
Expand All @@ -96,7 +102,6 @@ cs_sensor_download() {
found=1
break
fi
INDEX=$((INDEX+1))
done
if [ $found = 0 ]; then
die "Unable to locate matching sensor: $cs_os_name@$cs_os_version"
Expand Down Expand Up @@ -357,6 +362,14 @@ cs_os_version=$(
echo "$os_version" | awk -F'.' '{print $1}'
)

cs_os_architecture=$(
case $(uname -m) in
arm64) echo "arm64";;
aarch64) echo "arm64";;
*) echo "default";;
esac
)

aws_my_region=$(
curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone | sed s/.$//
)
Expand Down