Skip to content

Instantly share code, notes, and snippets.

@koter84
Last active July 29, 2019 19:06
Show Gist options
  • Save koter84/ca30eb9c3f216b10bbb0 to your computer and use it in GitHub Desktop.
Save koter84/ca30eb9c3f216b10bbb0 to your computer and use it in GitHub Desktop.
Update PhpStorm EAP version
#!/bin/bash
# get current dir
phpstorm_dir="/opt/$(ls /opt/ | grep PhpStorm)"
echo "PHPStorm DIR: $phpstorm_dir"
phpstorm_dir_version=$(echo $phpstorm_dir | awk -F/ '{print $NF}' | sed 's/PhpStorm-//')
echo "PHPStorm DIR Version: $phpstorm_dir_version"
# get current url
phpstorm_url=$(curl -s https://confluence.jetbrains.com/display/PhpStorm/PhpStorm+Early+Access+Program | sed 's/<a/\n<a/g' | grep 'href' | sed 's/.*http/http/g' | cut -d"\"" -f1 | grep '\.tar\.gz' | grep -v 'sha256')
echo "PHPStorm URL: $phpstorm_url"
phpstorm_url_version=$(echo $phpstorm_url | awk -F/ '{print $NF}' | sed 's/PhpStorm-EAP-//' | sed 's/\.tar\.gz//')
echo "PHPStorm URL Version: $phpstorm_url_version"
# check that a current version is found
if [ "$phpstorm_dir_version" == "" ]
then
echo "New Installation! (no old version found)"
new_install="1"
fi
# check that a new version and url are found
if [ "$phpstorm_url" == "" ] || [ "$phpstorm_url_version" == "" ]
then
echo "couldn't find url for new version"
exit
fi
# check current dir version with current url version
if [ "$phpstorm_dir_version" != "$phpstorm_url_version" ]
then
if [ "$new_install" != "1" ]
then
echo "New Version Found!"
fi
cd /opt/
# download
wget --quiet --show-progress -O phpstorm.new.tar.gz $phpstorm_url
# unpack
tar -zxf phpstorm.new.tar.gz
# remove download
rm phpstorm.new.tar.gz
if [ -h phpstorm ]
then
# remove symlink
rm phpstorm
fi
# create symlink
ln -s PhpStorm-$phpstorm_url_version/bin/phpstorm.sh phpstorm
if [ "$new_install" != "1" ]
then
# remove old version
rm -r PhpStorm-$phpstorm_dir_version
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment