-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·76 lines (69 loc) · 2.6 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
if [ "$1" = '--uninstall' ]; then
rm -rf $HOME/.local/bin/kx $HOME/.local/bin/kn
echo "Uninstall kn and kx from $HOME/.local/bin/kn $HOME/.local/bin/kx"
exit
fi
#### check curl
if ! [ -x "$(command -v curl)" ]; then
echo 'Error: curl is not installed.' >&2
exit 1
fi
installed_msg() {
echo ''
echo "Installed kn and kx ${TAG_NAME} at $HOME/.local/bin/kx $HOME/.local/bin/kn"
echo ''
echo ' Please add "$HOME/.local/bin" to your $PATH'
echo ' PATH="$PATH:$HOME/.local/bin"'
echo ''
}
install_kxkn() {
TAG_NAME=$1
OS=$2
ARCH=$3
KXKN=$4
#kn-v0.1.0-linux-arm64.tar.gz
cd /tmp
echo "Downloading ${KXKN}..."
curl -s https://github.com/koolwithk/kx-kn-rust/releases/download/${TAG_NAME}/${KXKN}-${TAG_NAME}-${OS}-${ARCH}.tar.gz -L --output ${KXKN}-${TAG_NAME}-${OS}-${ARCH}.tar.gz
tar -xzf ${KXKN}-${TAG_NAME}-${OS}-${ARCH}.tar.gz
rm -rf ${KXKN}-${TAG_NAME}-${OS}-${ARCH}.tar.gz
mkdir -p $HOME/.local/bin
mv ${KXKN} $HOME/.local/bin
}
#### check Architecture
if [ "$(uname -m | grep -o aarch64)" = "aarch64" ] || [ "$(uname -m | grep -o arm64)" = "arm64" ]; then
arch=arm64
elif [ "$(uname -m | grep -o x86_64)" = "x86_64" ] || [ "$(uname -m | grep -o amd64)" = "amd64" ] ; then
arch=x86_64
elif [ "$(uname -m | grep -o riscv64)" = "riscv64" ] || [ "$(uname -m | grep -o riscv64)" = "riscv64" ] ; then
arch=riscv64
else
echo "$(uname -m) $(uname) OS not supported by this script :("
fi
tag_name=$(curl -s "https://api.github.com/repos/koolwithk/kx-kn-rust/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
if [ "$(uname)" = "Linux" ] && [ "x86_64" = "$arch" ] ; then
os="linux"
install_kxkn "$tag_name" "$os" "$arch" "kx"
install_kxkn "$tag_name" "$os" "$arch" "kn"
installed_msg
elif [ "$(uname)" = "Linux" ] && [ "arm64" = "$arch" ] ; then
os="linux"
install_kxkn "$tag_name" "$os" "$arch" "kx"
install_kxkn "$tag_name" "$os" "$arch" "kn"
installed_msg
elif [ "$(uname)" = "Darwin" ] && [ "arm64" = "$arch" ] ; then
os="darwin"
install_kxkn "$tag_name" "$os" "$arch" "kx"
install_kxkn "$tag_name" "$os" "$arch" "kn"
installed_msg
echo 'for Apple Mac follow https://github.com/koolwithk/kx-kn-rust/issues/6 OR Build your own binary!!!'
echo ''
elif [ "$(uname)" = "Linux" ] && [ "riscv64" = "$arch" ] ; then
os="linux"
install_kxkn "$tag_name" "$os" "$arch" "kx"
install_kxkn "$tag_name" "$os" "$arch" "kn"
installed_msg
else
echo "$(uname -m) $(uname) OS not supported by this script :( Please install from release page."
fi