-
Notifications
You must be signed in to change notification settings - Fork 3
/
install.sh
executable file
·67 lines (51 loc) · 1.21 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
#!/bin/bash
# set -e
os=$(uname -s)
arch=$(uname -m)
if [ -e /tmp/zzz ]; then
rm -rf /tmp/zzz
fi
mkdir /tmp/zzz
cd /tmp/zzz
isChinaProxy="https://github.73zls.com/"
isChina=$(curl --silent "cip.cc" | grep "中国")
if [[ -z $isChina || "--no-china" == $1 || "1" == $NoChina ]]; then
isChinaProxy=""
fi
echo "Get Version..."
LAST_VERSION=$(curl --silent "${isChinaProxy}https://api.github.com/repos/sohaha/zzz/releases/latest" | grep "tag_name" | cut -d '"' -f 4 | cut -d 'v' -f 2)
if [[ "" == $LAST_VERSION ]]; then
echo "Failed to get version, please check the network"
exit 1
fi
if [[ "aarch64" == $arch ]]; then
arch="arm64"
fi
F="zzz_${LAST_VERSION/v/}_${os}_${arch}.tar.gz"
echo "Download tar.gz ..."
curl -O -L "${isChinaProxy}https://github.com/sohaha/zzz/releases/download/v${LAST_VERSION}/$F"
function cpzzz() {
if command -v sudo &> /dev/null; then
sudo cp -f zzz $P
else
cp -f zzz $P
fi
}
if [ $? -eq 0 ];then
echo "Untar..."
tar zxf "$F"
P="/usr/local/bin"
cpzzz
if [ $? -eq 0 ];then
echo "Install done"
else
P=$(echo $PATH | cut -d ':' -f 1)
cpzzz
fi
chmod +x "${P}/zzz"
"${P}/zzz" --help
rm -rf /tmp/zzz
else
echo "Install fail..."
exit
fi