Skip to content

Commit 48f6999

Browse files
authored
Merge pull request #424 from CrowdStrike/update-example-install
add support for arm64 and mac installs
2 parents 67722a8 + 0afdcdb commit 48f6999

File tree

1 file changed

+36
-26
lines changed

1 file changed

+36
-26
lines changed

examples/install

+36-26
Original file line numberDiff line numberDiff line change
@@ -13,47 +13,57 @@ os=$(
1313
)
1414

1515
arch=$(
16-
case $(uname -m) in x86_64) echo -n amd64 ;; aarch64) echo -n arm64 ;; *) echo -n $(uname -m) ;; esac
16+
uname -m
1717
)
1818

1919
latest_package_urls() {
2020
curl -s https://api.github.com/repos/crowdstrike/gofalcon/releases/latest | grep '"browser_download_url":' | sed 's/"$//g ; s/^.*browser_download_url": "//g'
2121
}
2222

23-
package_discriminator=$(
24-
case "${os}" in
25-
darwin)
26-
if [ "$arch" = "amd64" ]; then
27-
echo "macOS"
23+
case "${os}" in
24+
darwin)
25+
if [ "${arch}" = "amd64" ]; then
26+
package_discriminator="Darwin_x86_64"
27+
elif [ "${arch}" = "arm64" ]; then
28+
package_discriminator="Darwin_arm64"
29+
else
30+
die "Unsupported architecture for MacOS"
31+
fi
32+
;;
33+
linux)
34+
pkg_arch=$(
35+
if [ "${arch}" = "x86_64" ] || [ "${arch}" = "aarch64" ]; then
36+
echo "${arch}"
2837
else
29-
die "Unsupported architecture"
38+
die "Unsupported architecture for Linux"
3039
fi
31-
;;
32-
linux)
33-
pkg_arch=$(
34-
echo "$arch" | sed s/amd64/x86_64/g
35-
)
40+
)
41+
42+
if type rpm > /dev/null 2>&1; then
43+
package_discriminator="${pkg_arch}.rpm"
44+
elif type dpkg > /dev/null 2>&1; then
45+
package_discriminator="${pkg_arch}.deb"
46+
else
47+
die "Unsupported packaging system"
48+
fi
49+
;;
50+
*)
51+
die "Unsupported OS"
52+
;;
53+
esac
3654

37-
if type rpm > /dev/null 2>&1; then
38-
echo "${pkg_arch}.rpm"
39-
elif type dpkg > /dev/null 2>&1; then
40-
echo "${pkg_arch}.deb"
41-
else
42-
die "Unsupported packaging system"
43-
fi
44-
;;
45-
*)
46-
die "Unsupported OS"
47-
;;
48-
esac
49-
)
5055
package_url=$(
5156
latest_package_urls | grep "$package_discriminator"
5257
)
5358

5459
package_install() {
5560
pkg=$1
56-
if type dnf > /dev/null 2>&1; then
61+
if [ "$os" = "darwin" ]; then
62+
file=$(basename "$pkg")
63+
curl -LO "$pkg"
64+
tar -xzf "$file" -C /usr/local/bin/
65+
rm "$file"
66+
elif type dnf > /dev/null 2>&1; then
5767
dnf install -q -y "$pkg" || rpm -ivh --nodeps "$pkg"
5868
elif type yum > /dev/null 2>&1; then
5969
yum install -q -y "$pkg" || rpm -ivh --nodeps "$pkg"

0 commit comments

Comments
 (0)