-
Notifications
You must be signed in to change notification settings - Fork 34
/
install
executable file
·34 lines (27 loc) · 1.03 KB
/
install
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
#!/usr/bin/env sh
set -u
type curl > /dev/null || { echo "curl: not found"; exit 1; }
get_latest_release() {
curl --silent "https://api.github.com/repos/$repo/releases/latest" | # Get latest release from GitHub api
grep '"tag_name":' | # Get tag line
sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value
}
repo='huacnlee/autocorrect'
bin_name='autocorrect'
version=`get_latest_release`
platform="$(uname | tr "[A-Z]" "[a-z]")" # Linux => linux
arch="$(uname -m | sed 's/x86_64/amd64/')" # x86_64 => amd64
echo "Downloading $bin_name@$version ..."
libc=''
if ldd --version 2>&1 | grep -q 'musl'; then
libc='-musl'
fi
curl -Lo $bin_name.tar.gz https://github.com/$repo/releases/download/$version/$bin_name-$platform$libc-$arch.tar.gz
tar zxf $bin_name.tar.gz
if test $(id -u) -eq 0; then
mv $bin_name /usr/local/bin/$bin_name
else
sudo mv $bin_name /usr/local/bin/$bin_name
fi
rm $bin_name.tar.gz
echo "AutoCorrect $version has installed successfully."