Skip to content

Commit aa9694b

Browse files
updating install script to check for architecture and download the correct artifact (#409)
1 parent a524d87 commit aa9694b

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

install-guard.sh

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ main() {
1616
need_cmd ln
1717

1818
get_os_type
19+
get_arch_type
1920
get_latest_release |
2021
while
2122
read -r MAJOR_VER
@@ -24,11 +25,11 @@ main() {
2425
mkdir -p ~/.guard/"$MAJOR_VER" ~/.guard/bin ||
2526
err "unable to make directories ~/.guard/$MAJOR_VER, ~/.guard/bin"
2627
get_os_type
27-
download https://github.com/aws-cloudformation/cloudformation-guard/releases/download/"$VERSION"/cfn-guard-v"$MAJOR_VER"-"$OS_TYPE"-latest.tar.gz >/tmp/guard.tar.gz ||
28-
err "unable to download https://github.com/aws-cloudformation/cloudformation-guard/releases/download/$VERSION/cfn-guard-v$MAJOR_VER-$OS_TYPE-latest.tar.gz"
28+
download https://github.com/aws-cloudformation/cloudformation-guard/releases/download/"$VERSION"/cfn-guard-v"$MAJOR_VER"-"$ARCH_TYPE"-"$OS_TYPE"-latest.tar.gz >/tmp/guard.tar.gz ||
29+
err "unable to download https://github.com/aws-cloudformation/cloudformation-guard/releases/download/$VERSION/cfn-guard-v$MAJOR_VER-$ARCH_TYPE-$OS_TYPE-latest.tar.gz"
2930
tar -C ~/.guard/"$MAJOR_VER" -xzf /tmp/guard.tar.gz ||
3031
err "unable to untar /tmp/guard.tar.gz"
31-
ln -sf ~/.guard/"$MAJOR_VER"/cfn-guard-v"$MAJOR_VER"-"$OS_TYPE"-latest/cfn-guard ~/.guard/bin ||
32+
ln -sf ~/.guard/"$MAJOR_VER"/cfn-guard-v"$MAJOR_VER"-"$ARCH_TYPE"-"$OS_TYPE"-latest/cfn-guard ~/.guard/bin ||
3233
err "unable to symlink to ~/.guard/bin directory"
3334
~/.guard/bin/cfn-guard help ||
3435
err "cfn-guard was not installed properly"
@@ -88,4 +89,23 @@ download() {
8889
fi
8990
}
9091

92+
get_arch_type() {
93+
_archtype="$(uname -m)"
94+
case "$_archtype" in
95+
arm64)
96+
ARCH_TYPE="aarch64"
97+
;;
98+
aarch64)
99+
ARCH_TYPE="aarch64"
100+
;;
101+
x86_64)
102+
ARCH_TYPE="x86_64"
103+
;;
104+
105+
*)
106+
err "unsupported architecture type $_archtype"
107+
;;
108+
esac
109+
}
110+
91111
main

0 commit comments

Comments
 (0)