Created
September 24, 2021 12:56
-
-
Save kamilov/e4a7dba2a84a338c57c133a297635136 to your computer and use it in GitHub Desktop.
Jetbrains product install shell script
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
#!/usr/bin/env bash | |
if [[ $EUID -ne 0 ]]; then | |
echo "This script must be run as root. Use sudo." 1>&2 | |
exit 1 | |
fi | |
install_root="/opt" | |
bin_root="/usr/local/bin" | |
ide_get_latest_version() { | |
local code=${1} | |
curl https://data.services.jetbrains.com/products/releases?code=${code}\&release.type=release 2>/dev/null | sed -ne "s/,/,\n/gp" | grep "\"version\"" | head -1 | sed -ne "s/.*\"version\":\"\([^\"]\+\)\".*$/\1/p" | |
} | |
ide_install() { | |
local code=${1} | |
local name=${2} | |
local path=${3} | |
local version=`ide_get_latest_version ${code}` | |
local archive="${4:-${name}}-${version}.tar.gz" | |
local weblink="https://download.jetbrains.com/${path}/${archive}" | |
echo "Install ${name}" | |
wget -O "${install_root}/${archive}" ${weblink} | |
tar -xzf "${install_root}/${archive}" -C ${install_root} | |
local dist_dir=`tar tzf "${install_root}/${archive}" | head -1 | sed -e 's/\/.*//'` | |
rm -f "${install_root}/${archive}" | |
rm -rf "${install_root}/${name,,}" | |
mv "${install_root}/${dist_dir}" "${install_root}/${name,,}" | |
ln -sf "${install_root}/${name,,}/bin/${name,,}.sh" "${bin_root}/${name,,}" | |
} | |
while [[ $# -gt 0 ]]; do | |
case ${1} in | |
-ps|--phpstorm) | |
ide_install PS PhpStorm webide | |
shift | |
;; | |
-go|--goland) | |
ide_install GO goland go | |
shift | |
;; | |
-py|--pycharm) | |
ide_install PCC pycharm python pycharm-community | |
shift | |
;; | |
*) | |
echo "Unknown parameter: $1" 1>&2 | |
exit 1 | |
;; | |
esac | |
shift | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment