Skip to content
This repository was archived by the owner on Jan 25, 2023. It is now read-only.

Commit 69ec67c

Browse files
authored
Merge pull request #222 from izzyleung/master
Update install-consul logic to determine CPU arch which makes it run on Graviton based EC2 instances
2 parents af53a3f + 4824e42 commit 69ec67c

File tree

1 file changed

+42
-2
lines changed

1 file changed

+42
-2
lines changed

modules/install-consul/install-consul

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,48 @@ function fetch_binary {
166166
local -r version="$1"
167167
local download_url="$2"
168168

169-
if [[ -z "$download_url" && -n "$version" ]]; then
170-
download_url="https://releases.hashicorp.com/consul/${version}/consul_${version}_linux_amd64.zip"
169+
local cpu_arch
170+
cpu_arch="$(uname -m)"
171+
local binary_arch=""
172+
case "$cpu_arch" in
173+
x86_64)
174+
binary_arch="amd64"
175+
;;
176+
x86)
177+
binary_arch="386"
178+
;;
179+
arm64|aarch64)
180+
binary_arch="arm64"
181+
;;
182+
arm*)
183+
# The following info is taken from https://www.consul.io/downloads
184+
#
185+
# Note for ARM users:
186+
#
187+
# Use Armelv5 for all 32-bit armel systems
188+
# Use Armhfv6 for all armhf systems with v6+ architecture
189+
# Use Arm64 for all v8 64-bit architectures
190+
# The following commands can help determine the right version for your system:
191+
#
192+
# $ uname -m
193+
# $ readelf -a /proc/self/exe | grep -q -c Tag_ABI_VFP_args && echo "armhf" || echo "armel"
194+
#
195+
local vfp_tag
196+
vfp_tag="$(readelf -a /proc/self/exe | grep -q -c Tag_ABI_VFP_args)"
197+
if [[ -z $vfp_tag ]]; then
198+
binary_arch="armelv5"
199+
else
200+
binary_arch="armhfv6"
201+
fi
202+
;;
203+
*)
204+
log_error "CPU architecture $cpu_arch is not a supported by Consul."
205+
exit 1
206+
;;
207+
esac
208+
209+
if [[ -z "$download_url" && -n "$version" ]]; then
210+
download_url="https://releases.hashicorp.com/consul/${version}/consul_${version}_linux_${binary_arch}.zip"
171211
fi
172212

173213
retry \

0 commit comments

Comments
 (0)