-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathinstall
90 lines (79 loc) · 2.27 KB
/
install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/sh
set -e
die() {
echo "Fatal error: $*" >&2
echo "OS: '$os', Arch: '$arch', uname: '$(uname -a)'" >&2
exit 1
}
os=$(
uname | awk '{print tolower($0)}'
)
arch=$(
uname -m
)
latest_package_urls() {
curl -s https://api.github.com/repos/crowdstrike/gofalcon/releases/latest | grep '"browser_download_url":' | sed 's/"$//g ; s/^.*browser_download_url": "//g'
}
case "${os}" in
darwin)
if [ "${arch}" = "amd64" ]; then
package_discriminator="Darwin_x86_64"
elif [ "${arch}" = "arm64" ]; then
package_discriminator="Darwin_arm64"
else
die "Unsupported architecture for MacOS"
fi
;;
linux)
pkg_arch=$(
if [ "${arch}" = "x86_64" ] || [ "${arch}" = "aarch64" ]; then
echo "${arch}"
else
die "Unsupported architecture for Linux"
fi
)
if type rpm > /dev/null 2>&1; then
package_discriminator="${pkg_arch}.rpm"
elif type dpkg > /dev/null 2>&1; then
package_discriminator="${pkg_arch}.deb"
else
die "Unsupported packaging system"
fi
;;
*)
die "Unsupported OS"
;;
esac
package_url=$(
latest_package_urls | grep "$package_discriminator"
)
package_install() {
pkg=$1
if [ "$os" = "darwin" ]; then
file=$(basename "$pkg")
curl -LO "$pkg"
tar -xzf "$file" -C /usr/local/bin/
rm "$file"
elif type dnf > /dev/null 2>&1; then
dnf install -q -y "$pkg" || rpm -ivh --nodeps "$pkg"
elif type yum > /dev/null 2>&1; then
yum install -q -y "$pkg" || rpm -ivh --nodeps "$pkg"
elif type zypper > /dev/null 2>&1; then
zypper --quiet install -y "$pkg" || rpm -ivh --nodeps "$pkg"
elif type rpm > /dev/null 2>&1; then
rpm -ivh --nodeps "$pkg"
elif type apt-get > /dev/null 2>&1; then
file=$(curl -w "%{filename_effective}" -LO "$pkg")
dpkg -i "$file"
rm "$file"
else
die "Unsupported packaging system"
fi
}
package_install "$package_url"
echo " )"
echo " (__"
echo " _ )_"
echo " (_)_(_) Gofalcon examples installed"
echo " (o o) Use 'falcon_<<TAB>>' to discover installed binaries"
echo " ==\\o/=="