Repository navigation
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·72 lines (55 loc) · 1.52 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·72 lines (55 loc) · 1.52 KB
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
#!/bin/bash
set -euo pipefail
if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then
echo "Usage: $0 [version]"
echo
echo "If no version is provided, the latest release will be installed."
echo
echo "Examples:"
echo " $0 # installs the latest version"
echo " $0 0.2.0 # installs version 0.2.0"
exit 0
fi
OS=$(uname | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m)
case "$ARCH" in
x86_64) ARCH="amd64" ;;
aarch64 | arm64) ARCH="arm64" ;;
i386 | i686) ARCH="386" ;;
*)
echo "unsupported architecture: $ARCH" >&2
exit 1
;;
esac
VERSION=${1:-latest}
TMP_DIR=$(mktemp -d)
trap 'rm -rf "$TMP_DIR"' EXIT
if [ "$VERSION" = "latest" ]; then
VERSION=$(curl -s https://api.github.com/repos/ladzaretti/vlt-cli/releases/latest |
grep '"tag_name":' |
sed -E 's/.*"v([^"]+)".*/\1/')
fi
if [[ -z "$VERSION" ]]; then
echo "failed to determine version" >&2
exit 1
fi
echo "preparing install:"
echo " OS : $OS"
echo " ARCH : $ARCH"
echo " VERSION : $VERSION"
TARBALL=vlt_${VERSION}_${OS}_${ARCH}.tar.gz
DEST="$TMP_DIR"/"$TARBALL"
URL="https://github.com/ladzaretti/vlt-cli/releases/download/v$VERSION/$TARBALL"
echo "downloading $URL..."
curl -sSL --fail-with-body -o "$DEST" "$URL"
echo "OK."
echo "extracting archive..."
tar -xz -C "$TMP_DIR" -f "$DEST"
echo "OK."
cd "$TMP_DIR/vlt_${VERSION}_${OS}_${ARCH}"
echo "running installer..."
if [[ ! -x install.sh ]]; then
echo "install.sh not found or not executable in $PWD" >&2
exit 1
fi
./install.sh