forked from l7mp/stunner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetstunner.sh
executable file
·80 lines (66 loc) · 2.12 KB
/
getstunner.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
#!/bin/sh
# STUNner tools downloader script
#
# inspired by https://raw.githubusercontent.com/istio/istio/master/release/downloadIstioCtl.sh
REPO=l7mp/stunner
# Determine OS
OS="${TARGET_OS:-$(uname)}"
if [ "${OS}" = "Darwin" ] ; then
OSEXT="darwin"
else
OSEXT="linux"
fi
# Determine the latest STUNner version
if [ "${STUNNER_VERSION}" = "" ] ; then
STUNNER_VERSION="$(curl -Lsf https://api.github.com/repos/${REPO}/releases/latest \
| grep -o '"tag_name": "v[0-9]*.[0-9]*.[0-9]*' \
| awk -F'"' '{print $4}')"
STUNNER_VERSION="${STUNNER_VERSION##*/}"
fi
# Determine build params
if [ "${STUNNER_VERSION}" = "" ] ; then
printf "Unable to get latest Stunner version. Set STUNNER_VERSION env var and re-run. For example: export STUNNER_VERSION=0.18.0"
exit 1;
fi
LOCAL_ARCH=$(uname -m)
if [ "${TARGET_ARCH}" ]; then
LOCAL_ARCH=${TARGET_ARCH}
fi
case "${LOCAL_ARCH}" in
x86_64|amd64)
STUNNER_ARCH=amd64
;;
armv8*|aarch64*|arm64)
STUNNER_ARCH=arm64
;;
*)
echo "This system's architecture, ${LOCAL_ARCH}, isn't supported"
exit 1
;;
esac
# Download binaries
progs="stunnerctl turncat"
tmp=$(mktemp -d /tmp/stunner.XXXXXX)
for prog in $progs; do
NAME="${prog}-${STUNNER_VERSION}"
URL="/~https://github.com/${REPO}/releases/download/${STUNNER_VERSION}/${prog}-${STUNNER_VERSION}-${OSEXT}-${STUNNER_ARCH}"
filename="${prog}-${STUNNER_VERSION}-${OSEXT}-${STUNNER_ARCH}"
printf "\nDownloading %s from %s ...\n" "${NAME}" "$URL"
if ! curl -o /dev/null -sIf "$URL"; then
printf "\n%s is not found, please specify a valid STUNNER_VERSION and TARGET_ARCH\n" "$URL"
exit 1
fi
curl -fsL -o "${tmp}/${filename}" "$URL"
printf "%s download complete!\n" "${filename}"
mkdir -p "$HOME/.l7mp/bin"
mv "${tmp}/${filename}" "$HOME/.l7mp/bin/${prog}"
chmod +x "$HOME/.l7mp/bin/${prog}"
done
rm -r "${tmp}"
# Print final message
printf "\n"
printf "Add stunner tools to your path with:"
printf "\n"
printf " export PATH=\$HOME/.l7mp/bin:\$PATH \n"
printf "\n"
printf "Need more information? Visit https://docs.l7mp.io/en/${STUNNER_VERSION}/ \n"