-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
executable file
·71 lines (58 loc) · 1.36 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
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
#!/usr/bin/env bash
set -euo pipefail
version="0.13.6"
cd "$(dirname "${BASH_SOURCE[0]}")"
skim_base="$(pwd)"
check_binary() {
echo "Checking skim executable and version... "
local output
output=$("$skim_base"/bin/sk --version 2>&1)
if [ $? -ne 0 ]; then
echo "Error: $output"
elif [ "$version" != "$output" ]; then
echo "$output != $version"
else
echo "Done: $output"
return 0
fi
rm -f "$skim_base"/bin/sk
return 1
}
# download version
download() {
echo "Downloading bin/sk ..."
mkdir -p "$skim_base"/bin && cd "$skim_base"/bin
if [ $? -ne 0 ]; then
binary_error="Failed to create bin directory"
return
fi
local url=https://github.com/LoricAndre/skimmer/releases/download/v$version/${1}.tgz
echo "Downloading: $url"
if command -v curl > /dev/null; then
curl -fL $url | tar xz
elif command -v wget > /dev/null; then
wget -O - $url | tar xz
else
binary_error="curl or wget not found"
return
fi
if [ ! -f $1 ]; then
binary_error="Failed to download ${1}"
return
fi
}
case "$(uname -s)" in
"Darwin") os="apple-darwin" ;;
"Linux") os="unknown-linux-musl" ;;
*) ;;
esac
case "$(uname -m)" in
"x86_64" | "x64") arch="x86_64" ;;
"aarch64") arch="aarch64" ;;
"armv7" | "armv7l") arch="armv7" ;;
"arm") arch="arm" ;;
*) ;;
esac
download "skim-${arch}-${os}"
check_binary
echo "Done :)"