-
Notifications
You must be signed in to change notification settings - Fork 32
/
install.sh
59 lines (52 loc) · 1.56 KB
/
install.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
#!/bin/bash
REPOOWNER="ekkinox"
REPONAME="yai"
RELEASETAG=$(curl -s "https://api.github.com/repos/$REPOOWNER/$REPONAME/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
KERNEL=$(uname -s 2>/dev/null || /usr/bin/uname -s)
case ${KERNEL} in
"Linux"|"linux")
KERNEL="linux"
;;
"Darwin"|"darwin")
KERNEL="darwin"
;;
*)
output "OS '${KERNEL}' not supported" "error"
exit 1
;;
esac
MACHINE=$(uname -m 2>/dev/null || /usr/bin/uname -m)
case ${MACHINE} in
arm|armv7*)
MACHINE="arm"
;;
aarch64*|armv8*|arm64)
MACHINE="arm64"
;;
i[36]86)
MACHINE="386"
if [ "darwin" = "${KERNEL}" ]; then
output " [ ] Your architecture (${MACHINE}) is not supported anymore" "error"
exit 1
fi
;;
x86_64)
MACHINE="amd64"
;;
*)
output " [ ] Your architecture (${MACHINE}) is not currently supported" "error"
exit 1
;;
esac
BINNAME="${BINNAME:-yai}"
BINDIR="${BINDIR:-/usr/local/bin}"
URL="https://github.com/$REPOOWNER/$REPONAME/releases/download/${RELEASETAG}/yai_${RELEASETAG}_${KERNEL}_${MACHINE}.tar.gz"
echo "Downloading version $RELEASETAG from $URL"
echo
curl -q --fail --location --progress-bar --output "yai_${RELEASETAG}_${KERNEL}_${MACHINE}.tar.gz" "$URL"
tar xzf "yai_${RELEASETAG}_${KERNEL}_${MACHINE}.tar.gz"
chmod +x $BINNAME
sudo mv $BINNAME $BINDIR/$BINNAME
rm "yai_${RELEASETAG}_${KERNEL}_${MACHINE}.tar.gz"
echo
echo "Installation of version $RELEASETAG complete!"