forked from nicolaka/netshoot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfetch_binaries.sh
executable file
·85 lines (75 loc) · 2.4 KB
/
fetch_binaries.sh
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
#!/usr/bin/env bash
set -euo pipefail
get_latest_release() {
curl --silent "https://api.github.com/repos/$1/releases/latest" | # Get latest release from GitHub api
grep '"tag_name":' | # Get tag line
sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value
}
ARCH=$(uname -m)
case $ARCH in
x86_64)
ARCH=amd64
;;
aarch64)
ARCH=arm64
;;
esac
get_ctop() {
VERSION=$(get_latest_release bcicen/ctop | sed -e 's/^v//')
LINK="https://github.com/bcicen/ctop/releases/download/v${VERSION}/ctop-${VERSION}-linux-${ARCH}"
wget "$LINK" -O /tmp/ctop && chmod +x /tmp/ctop
}
get_calicoctl() {
VERSION=$(get_latest_release projectcalico/calicoctl)
LINK="https://github.com/projectcalico/calicoctl/releases/download/${VERSION}/calicoctl-linux-${ARCH}"
wget "$LINK" -O /tmp/calicoctl && chmod +x /tmp/calicoctl
}
get_termshark() {
case "$ARCH" in
*)
VERSION=$(get_latest_release gcla/termshark | sed -e 's/^v//')
if [ "$ARCH" == "amd64" ]; then
TERM_ARCH=x64
else
TERM_ARCH="$ARCH"
fi
LINK="https://github.com/gcla/termshark/releases/download/v${VERSION}/termshark_${VERSION}_linux_${TERM_ARCH}.tar.gz"
wget "$LINK" -O /tmp/termshark.tar.gz && \
tar -zxvf /tmp/termshark.tar.gz && \
mv "termshark_${VERSION}_linux_${TERM_ARCH}/termshark" /tmp/termshark && \
chmod +x /tmp/termshark
;;
esac
}
get_grpcurl() {
if [ "$ARCH" == "amd64" ]; then
TERM_ARCH=x86_64
else
TERM_ARCH="$ARCH"
fi
VERSION=$(get_latest_release fullstorydev/grpcurl | sed -e 's/^v//')
LINK="https://github.com/fullstorydev/grpcurl/releases/download/v${VERSION}/grpcurl_${VERSION}_linux_${TERM_ARCH}.tar.gz"
wget "$LINK" -O /tmp/grpcurl.tar.gz && \
tar --no-same-owner -zxvf /tmp/grpcurl.tar.gz && \
mv "grpcurl" /tmp/grpcurl && \
chmod +x /tmp/grpcurl
chown root:root /tmp/grpcurl
}
get_fortio() {
if [ "$ARCH" == "amd64" ]; then
TERM_ARCH=x86_64
else
TERM_ARCH="$ARCH"
fi
VERSION=$(get_latest_release fortio/fortio | sed -e 's/^v//')
LINK="https://github.com/fortio/fortio/releases/download/v${VERSION}/fortio-linux_${ARCH}-${VERSION}.tgz"
wget "$LINK" -O /tmp/fortio.tgz && \
tar -zxvf /tmp/fortio.tgz && \
mv "usr/bin/fortio" /tmp/fortio && \
chmod +x /tmp/fortio
}
get_ctop
get_calicoctl
get_termshark
get_grpcurl
get_fortio