Last active
March 26, 2021 22:04
-
-
Save zabidok/8418c4f679741f585ac9ce90b16fb8a5 to your computer and use it in GitHub Desktop.
Install or update jetbrains products like PhpStorm, WebStorm, IntelliJ Idea, PyCharm, CLion, ReSharper on Ubuntu and fix problems with non latin hotkeys in gui java application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# installation jetbrains | |
j_url="https://data.services.jetbrains.com/products/download" | |
tmp_dir="$HOME/tmp_jb" | |
install_dir="/opt" | |
if [ "$(whoami)" != "root" ] | |
then | |
echo "Sorry, you are not root." | |
exit 1 | |
fi | |
echo "Please select jetbrains product: " | |
options=('Install Oracle Java 8' 'PhpStorm' 'WebStorm' 'IntelliJ Idea Ultimate' 'IntelliJ Idea Community' 'PyCharm' 'CLion' 'ReSharper' 'Quit') | |
selected='' | |
select opt in "${options[@]}" | |
do | |
opt_sm=${opt,,} | |
case $opt in | |
'Install Oracle Java 8') | |
echo "Remove OpenJDK" | |
apt-get remove openjdk* | |
echo "Add the PPA and install Oracle Java 8" | |
add-apt-repository ppa:webupd8team/java | |
apt-get update | |
apt-get install java-common oracle-java8-installer | |
apt-get install oracle-java8-set-default | |
source /etc/profile | |
echo "Oracle Java 8" | |
break | |
;; | |
'PhpStorm') | |
selected='PS' | |
;; | |
'WebStorm') | |
selected='WS' | |
;; | |
'IntelliJ Idea Ultimate') | |
selected='IIU' | |
opt_sm='ideaIU' | |
;; | |
'IntelliJ Idea Community') | |
selected='IIC' | |
opt_sm='ideaIC' | |
;; | |
'PyCharm') | |
selected='PCP' | |
;; | |
'CLion') | |
selected='CL' | |
;; | |
'ReSharper') | |
selected='RS' | |
;; | |
'Quit') | |
break | |
;; | |
*) echo invalid option;; | |
esac | |
realurl=$(curl -w "%{url_effective}\n" -I -L -s -S $j_url?code=$selected\&platform=linux -o /dev/null) | |
filename=$(basename "$realurl") | |
file_dir=${filename%.tar*} | |
file_ver=${file_dir##*-} | |
tar_file=$tmp_dir/$filename | |
tar_file_dir=$tmp_dir/$file_dir | |
new_install_dir=$install_dir/$opt_sm | |
if [ -d "$new_install_dir" ]; then | |
echo "Found installed $opt" | |
if [ -f "$new_install_dir/$file_ver" ] | |
then | |
echo "Current version is $file_ver, no updates." | |
break; | |
else | |
echo "Version file not found, lets update this" | |
echo "Looks like we got new version - $file_ver" | |
fi | |
else | |
echo "Not installed before, current version is $file_ver" | |
fi | |
echo "Downloading $opt to $tmp_dir" | |
mkdir $tmp_dir | |
cd $tmp_dir | |
wget ${realurl} --no-check-certificate | |
echo "Extracting $filename to $file_dir" | |
mkdir $file_dir | |
tar -xzf $tar_file -C $file_dir | |
echo "Move files UP" | |
dirs=($tar_file_dir/*/) | |
child_dir=${dirs[0]} | |
mv $child_dir* $tar_file_dir | |
echo "Removing $child_dir" | |
rm -rf $child_dir | |
echo "Removing $filename" | |
rm $tar_file | |
if [ -d "$new_install_dir" ]; then | |
echo "Removing old link" | |
rm /usr/local/bin/$opt_sm | |
echo "Removing old $opt from $new_install_dir" | |
rm -rf $new_install_dir | |
fi | |
echo "Copying new $opt to $new_install_dir" | |
mv $tar_file_dir* $new_install_dir | |
echo "Create version file" | |
touch $install_dir/$opt_sm/$file_ver | |
fix_file=$opt_sm; | |
if [[ $fix_file == ideaI* ]]; then | |
fix_file="idea" | |
fi | |
echo "Creating link - $opt_sm" | |
ln -s $new_install_dir/bin/$fix_file.sh /usr/local/bin/$opt_sm | |
echo "Fix problems with non latin hotkeys in gui java applications" | |
cd $install_dir | |
echo "Get fixes from git" | |
git clone https://github.com/zheludkovm/LinuxJavaFixes.git fix | |
echo "Check system" | |
MACHINE_TYPE=`uname -m` | |
if [ ${MACHINE_TYPE} == 'x86_64' ]; then | |
echo "Detected 64 bit" | |
fix_file=$fix_file"64" | |
fi | |
echo "-javaagent:$install_dir/fix/build/LinuxJavaFixes-1.0.0-SNAPSHOT.jar" >> $new_install_dir/bin/$fix_file.vmoptions | |
echo "Fix installed!" | |
echo "Removing $tmp_dir" | |
rm -rf $tmp_dir | |
break | |
done |
Thanks!!
Love it, works like a charm! Thanks 👍
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
jb_install_update.sh: 13: jb_install_update.sh: Syntax error: "(" unexpected
Сорян. Запускал sh, а не bash