-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.sh
executable file
·93 lines (69 loc) · 2.07 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/env bash
# shellcheck disable=SC2181
# Reset
Color_Off=''
# Regular Colors
Red=''
Green=''
# Bold
BGreen=''
Dim='' # White
if test -t 1; then
# Reset
Color_Off='\033[0m' # Text Reset
# Regular Colors
Red='\033[0;31m' # Red
Green='\033[0;32m' # Green
Dim='\033[0;2m' # White
# Bold
BGreen='\033[1;32m' # Green
fi
case $(uname -sm) in
"Darwin x86_64") target="x86_64-apple-darwin" ;;
"Darwin arm64") target="aarch64-apple-darwin" ;;
"Linux aarch64") target="aarch64-unknown-linux-gnu" ;;
"Linux arm64") target="aarch64-unknown-linux-gnu" ;;
"Linux x86_64") target="x86_64-unknown-linux-gnu" ;;
*) target="x86_64-unknown-linux-gnu" ;;
esac
if [ "$target" = "x86_64-apple-darwin" ]; then
# Is it rosetta?
sysctl sysctl.proc_translated >/dev/null 2>&1
if [ $? -eq 0 ]; then
target="aarch64-apple-darwin"
echo -e "$Dim Your shell is running in Rosetta 2. Downloading jimaku for $target instead. $Color_Off"
fi
fi
github_repo="https://github.com/aeyoll/jimaku"
if [ $# -eq 0 ]; then
jimaku_uri="$github_repo/releases/latest/download/jimaku-${target}.tar.gz"
else
jimaku_uri="$github_repo/releases/download/${1}/jimaku-${target}.tar.gz"
fi
jimaku_install="${JIMAKU_INSTALL:-$HOME/.jimaku}"
bin_dir="$jimaku_install/bin"
exe="$bin_dir/jimaku"
if [ ! -d "$bin_dir" ]; then
mkdir -p "$bin_dir"
if (($?)); then
echo -e "${Red}error${Color_Off}: Failed to create install directory $bin_dir" 1>&2
exit 1
fi
fi
curl --fail --location --progress-bar --output "$exe.tar.gz" "$jimaku_uri"
if (($?)); then
echo -e "${Red}error${Color_Off}: Failed to download jimaku from $jimaku_uri" 1>&2
exit 1
fi
tar xvzf "$exe.tar.gz" -C "$bin_dir"
if (($?)); then
echo -e "${Red}error${Color_Off}: Failed to extract jimaku" 1>&2
exit 1
fi
chmod +x "$exe"
if (($?)); then
echo -e "${Red}error${Color_Off}: Failed to set permissions on jimaku executable." 1>&2
exit 1
fi
rm "$exe.tar.gz"
echo -e "${Green}jimaku was installed successfully to ${BGreen}$exe$Color_Off"