-
Notifications
You must be signed in to change notification settings - Fork 0
/
user-install-jetbrains-toolbox
executable file
·83 lines (64 loc) · 1.77 KB
/
user-install-jetbrains-toolbox
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
#!/usr/bin/env sh
# This script installs JetBrains Toolbox, which is a tool to manage JetBrains IDEs.
# https://www.jetbrains.com/toolbox-app/
set -eu
SCRIPTS_DIR="${HOME}/.local/bin"
INSTALL_DIR="${HOME}/.local/share/JetBrains/Toolbox"
install_jetbrains_toolbox() {
echo "Jetbrains Toolbox Installer"
echo "---------------------------"
echo
ask_for_confirmation "Installing JetBrains Toolbox to ${INSTALL_DIR}."
create_directories
download_toolbox_and_install_it
create_settings_file
start_toolbox
}
create_directories() {
echo "Creating directories..."
mkdir -p "${SCRIPTS_DIR}" "${INSTALL_DIR}"
}
# $1 - The message to display.
ask_for_confirmation() {
echo "$1"
printf "Do you want to continue? [Y/n] "
read -r answer
case "${answer}" in
[yY] | [yY][eE][sS] | "") ;;
*)
echo "Aborting..."
exit 1
;;
esac
}
download_toolbox_and_install_it() {
echo "Determining download link..."
DL_LINK=$(curl -fsSL "https://data.services.jetbrains.com/products/releases?code=TBA&latest=true&type=release" | jq -r ".TBA[0].downloads.linux.link")
echo "Downloading ${DL_LINK}..."
curl -fsSL "${DL_LINK}" | tar -xz --strip-components=1 -C "${INSTALL_DIR}"/bin
echo "Creating symlink..."
ln -fs "${INSTALL_DIR}"/bin/jetbrains-toolbox "${SCRIPTS_DIR}"/jetbrains-toolbox
}
create_settings_file() {
echo "Creating settings file..."
cat <<-EOF >"${INSTALL_DIR}"/.settings.json
{
"autostart": false,
"install_location": "${INSTALL_DIR}",
"channel_rollback_max_history": 1,
"shell_scripts": {
"location": "${SCRIPTS_DIR}"
},
"network": {
"keystore": {
"location": "/etc/pki/java/cacerts"
}
}
}
EOF
}
start_toolbox() {
echo "Starting JetBrains Toolbox..."
("${SCRIPTS_DIR}"/jetbrains-toolbox &) >/dev/null 2>&1
}
install_jetbrains_toolbox "$@"