-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathinstall.sh
executable file
·75 lines (62 loc) · 1.76 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
set -e
BIN_PATH=$HOME/.local/bin
BIN_NAME=paddle
PADDLE_WRAPPER_URL='https://raw.githubusercontent.com/JetBrains-Research/paddle/master/scripts/paddle.sh' # native image wrapper
PADDLE_JAR_WRAPPER_URL='https://raw.githubusercontent.com/JetBrains-Research/paddle/master/scripts/paddle-jar.sh' # jar wrapper
FIRST_ARG=$1
download_wrapper() {
mkdir -p "${BIN_PATH}"
if [[ ${FIRST_ARG} == "jar" ]]; then
curl -s ${PADDLE_JAR_WRAPPER_URL} -o "${BIN_PATH}/${BIN_NAME}"
else
curl -s ${PADDLE_WRAPPER_URL} -o "${BIN_PATH}/${BIN_NAME}"
fi
chmod +x "${BIN_PATH}/${BIN_NAME}"
}
check_path() {
if [[ $(echo "$PATH" | grep "${BIN_PATH}") == "" ]]; then
echo "Looks like $BIN_PATH is not in path. Would you like to set it automatically? (yes/no):"
read -r confirmation
[[ ${confirmation} == "yes" ]] && set_path
fi
}
set_path() {
local sh_rc_path=''
local export_path=''
# shellcheck disable=SC2016
case $SHELL in
/bin/bash)
sh_rc_path=$HOME/.bashrc
export_path='export PATH="$HOME/.local/bin:$PATH"'
;;
/bin/zsh)
sh_rc_path=$HOME/.zshrc
export_path='export PATH="$HOME/.local/bin:$PATH"'
;;
/bin/tcsh)
sh_rc_path=$HOME/.tcshrc
export_path='set path = ($path $HOME/.local/bin)'
;;
/bin/kshrc)
sh_rc_path=$HOME/.kshrc
export_path='export PATH="$HOME/.local/bin:$PATH"'
;;
/bin/fish)
sh_rc_path=$HOME/.config/fish/config.fish
export_path='set -gx PATH $HOME/.local/bin $PATH'
;;
*)
echo "Unknown shell: $SHELL"
exit 1
;;
esac
grep -qxF "${export_path}" "${sh_rc_path}" || echo "${export_path}" >>"${sh_rc_path}"
echo "Please, reload your shell or run 'source ${sh_rc_path}' to update PATH variable"
}
main() {
download_wrapper
check_path
}
main
exit 0