forked from solo-io/wasm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_cli.sh
executable file
·66 lines (53 loc) · 1.84 KB
/
install_cli.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
#!/bin/sh
set -eu
if [ -z "${WASME_VERSION:-}" ]; then
WASME_VERSIONS=$(curl -sH"Accept: application/vnd.github.v3+json" https://api.github.com/repos/solo-io/wasme/releases | python -c "import sys; from distutils.version import LooseVersion; from json import loads as l; releases = l(sys.stdin.read()); releases = [release['tag_name'] for release in releases if not release['prerelease'] ]; releases.sort(key=LooseVersion, reverse=True); print('\n'.join(releases))")
else
WASME_VERSIONS="${WASME_VERSION}"
fi
if [ "$(uname -s)" = "Darwin" ]; then
OS=darwin
else
OS=linux
fi
for WASME_VERSION in $WASME_VERSIONS; do
tmp=$(mktemp -d /tmp/wasme.XXXXXX)
filename="wasme-${OS}-amd64"
url="https://github.com/solo-io/wasme/releases/download/${WASME_VERSION}/${filename}"
if curl -f ${url} -v > /dev/null 2>&1; then
echo "Attempting to download Wasme CLI version ${WASME_VERSION}"
else
continue
fi
(
cd "$tmp"
echo "Downloading ${filename}..."
SHA=$(curl -sL "${url}.sha256" | cut -d' ' -f1)
curl -sLO "${url}"
echo "Download complete!, validating checksum..."
checksum=$(openssl dgst -sha256 "${filename}" | awk '{ print $2 }')
if [ "$checksum" != "$SHA" ]; then
echo "Checksum validation failed." >&2
exit 1
fi
echo "Checksum valid."
)
(
cd "$HOME"
mkdir -p ".wasme/bin"
mv "${tmp}/${filename}" ".wasme/bin/wasme"
chmod +x ".wasme/bin/wasme"
)
rm -r "$tmp"
echo "Wasme CLI was successfully installed 🎉"
echo ""
echo "Add the Wasme CLI to your path with:"
echo " export PATH=\$HOME/.wasme/bin:\$PATH"
echo ""
echo "Now run:"
echo " wasme init myfilter # generate a new filter directory"
echo "Please see visit the WebAssembly Hub guides for more: https://docs.solo.io/web-assembly-hub/latest"
exit 0
done
echo "No versions of wasme found."
exit 1