-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
executable file
·75 lines (59 loc) · 1.92 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
#!/usr/bin/env bash
PLATFORM=uname
SOURCE=https://raw.githubusercontent.com/adiatma/intip/master/intip.sh
BIN_LOCATION="/usr/local/bin/"
JQ_BIN_LOCATION=/usr/local/bin/jq
JQ_VERSION=jq-1.6
JQ_OSX=jq-osx-amd64
JQ_LINUX=jq-linux64
JQ_DOWNLOAD=https://github.com/stedolan/jq/releases/download
progress_bar() {
local duration=${1}
already_done() { for ((done=0; done<$elapsed; done++)); do printf ":"; done }
remaining() { for ((remain=$elapsed; remain<$duration; remain++)); do printf " "; done }
percentage() { printf "| %s%%" $(( (($elapsed)*100)/($duration)*100/100 )); }
clean_line() { printf "\r"; }
for (( elapsed=1; elapsed<=$duration; elapsed++ )); do
already_done; remaining; percentage
clean_line
done
clean_line
}
download_and_install_intip() {
command curl -fsSL ${SOURCE} -o $HOME/intip.sh
command mv $HOME/intip.sh $BIN_LOCATION
command chmod +x $BIN_LOCATION/intip.sh
}
download_and_install_jq() {
if [[ "$PLATFORM" -eq "Darwin" ]]; then
command curl -fsSL "$JQ_DOWNLOAD/$JQ_VERSION/$JQ_OSX" -o $HOME/jq
command mv $HOME/jq $JQ_BIN_LOCATION
command chmod +x $JQ_BIN_LOCATION
elif [[ "$PLATFORM" -eq "Linux" ]]; then
command curl -fsSL "$JQ_DOWNLOAD/$JQ_VERSION/$JQ_LINUX" -o $HOME/jq
command mv $HOME/jq $JQ_BIN_LOCATION
command chmod +x $JQ_BIN_LOCATION
else
echo "😥 Sorry currently just support (OSX|Linux), please install jq by manual"
fi
}
main() {
if [[ ! -s "$JQ_BIN_LOCATION" ]]; then
echo "🚀 download and install jq"
progress_bar 100
printf "\n"
download_and_install_jq
fi
echo "🚀 download and install intip.sh"
progress_bar 100
printf "\n"
download_and_install_intip
}
main
cat <<EOF
intip.sh 👀
Yey, congratulations, intip.sh success to install in your computer.
* Please try to execute intip.sh --inline.
* Please don't forget to click the star in https://github.com/adiatma/intip
thanks :)
EOF