-
Notifications
You must be signed in to change notification settings - Fork 1
/
dl.sh
executable file
·61 lines (51 loc) · 1.28 KB
/
dl.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
#!/bin/sh
set -e -u
binary_arch="none"
binary_os="none"
tmpdir="${TMPDIR-"/tmp/"}/lico"
url=""
dest="/usr/local/bin/lico"
# Get os info
uname_march="$(uname -m | tr '[:upper:]' '[:lower:]')"
uname_os="$(uname -o | tr '[:upper:]' '[:lower:]')"
# Check and format os
case "${uname_march}" in
"arm64" | "x86_64")
binary_arch="$uname_march"
;;
esac
case "${uname_os}" in
"gnu/linux")
binary_os="Linux"
;;
"darwin")
binary_os="Darwin"
;;
*"windows"*)
echo "Windows is not supported by this script" >&2
exit 1
;;
esac
if [ "$binary_arch" = "none" ] || [ "$binary_os" = "none" ]; then
{
echo "Unknown OS or Architecture"
echo "OS: ${uname_os} Arch: ${uname_march}"
} >&2
exit 1
fi
# Check command line tools
for t in "curl" "tar"; do
if ! which "$t" >/dev/null 2>&1; then
echo "$t should be installed" >&2
exit 1
fi
done
# Run download
url="https://github.com/Hayao0819/lico/releases/latest/download/lico_${binary_os}_${binary_arch}.tar.gz"
echo "Downloading $url" >&2
mkdir -p "$tmpdir"
curl -f -L -o "$tmpdir/archive.tar.gz" "$url"
# Extract and install
tar xf "$tmpdir/archive.tar.gz" -C "$tmpdir"
sudo cp "$tmpdir/lico" "$dest"
echo "lico has been installed in $dest" >&2