Last active
September 13, 2017 12:37
-
-
Save matthiasbayer/741e8a4774227c940445 to your computer and use it in GitHub Desktop.
Install or update Jetbrains Software to latest EAP or stable version
This file contains hidden or 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 | |
case "${1}" in | |
"phpstorm") | |
TOOL_NAME="PhpStorm" | |
INSTALL_DIR="/opt/phpstorm" | |
EAP_URL="https://confluence.jetbrains.com/display/PhpStorm/PhpStorm+Early+Access+Program" | |
EAP_FILE="PhpStorm-EAP-[0-9\.]+(:?[a-z\-]+)?.tar.gz" | |
STABLE_URL="https://confluence.jetbrains.com/display/PhpStorm/Previous+PhpStorm+Releases" | |
STABLE_FILE="PhpStorm-[0-9\.]+.tar.gz" | |
DOWNLOAD_URL="http://download-cf.jetbrains.com/webide/" | |
;; | |
"pycharm") | |
TOOL_NAME="PyCharm" | |
INSTALL_DIR="/opt/pycharm" | |
EAP_URL="http://confluence.jetbrains.com/display/PYH/JetBrains+PyCharm+Preview+%28EAP%29" | |
EAP_FILE="pycharm-professional-[0-9\.]+(:?[a-z\-]+)?.tar.gz" | |
STABLE_URL="https://confluence.jetbrains.com/display/PYH/Previous+PyCharm+Releases" | |
STABLE_FILE="PyCharm-professional-[0-9\.]+.tar.gz" | |
DOWNLOAD_URL="http://download.jetbrains.com/python/" | |
;; | |
*) | |
echo "Not supported" | |
exit 1 | |
esac | |
echo "Checking for ${TOOL_NAME} updates..." | |
BUILD_FILE="${INSTALL_DIR}/build.txt" | |
FILE=$(curl -s "${EAP_URL}" | grep -Eo "${EAP_FILE}" | head -1) | |
VERSION=$(echo $FILE | grep -Eo "([0-9]+\.[0-9]+)") | |
URL="${DOWNLOAD_URL}${FILE}" | |
if [ -z "${VERSION}" ] | |
then | |
echo "No EAP release available, using last stable" | |
FILE=$(curl -s "${STABLE_URL}" | grep -Eo "${STABLE_FILE}" | head -1) | |
VERSION=$(echo $FILE | grep -Eo "([0-9]+\.[0-9]+(:?\.[0-9]+)?)") | |
URL="${DOWNLOAD_URL}${FILE}" | |
fi | |
if [ -z "${VERSION}" ] | |
then | |
echo "ERROR: No release found" | |
exit 1 | |
fi | |
# Check current installed version if available | |
if [ -f "${BUILD_FILE}" ] | |
then | |
CURRENT_VERSION=$(cat ${INSTALL_DIR}/build.txt | grep -Eo "([0-9]+\.[0-9]+)") | |
echo "Found ${TOOL_NAME}-EAP-${CURRENT_VERSION} at ${INSTALL_DIR}" | |
if [ "${CURRENT_VERSION}" == "${VERSION}" ] | |
then | |
echo "You have the latest version of ${TOOL_NAME} EAP already installed." | |
exit | |
fi | |
else | |
echo "No ${TOOL_NAME} found at ${INSTALL_DIR}" | |
fi | |
echo "Updating to ${TOOL_NAME} ${VERSION}" | |
TMP_DIR="/tmp/${TOOL_NAME}-tmp-${VERSION}" | |
TMP_FILE="${TMP_DIR}/${FILE}" | |
EXTRACTED="${TMP_DIR}/*-${VERSION}*" | |
# Create tmp dirctory for download and extracting | |
if [ ! -d "${TMP_DIR}" ] | |
then | |
mkdir "${TMP_DIR}" | |
fi | |
# Check if already extracted | |
if [ ! -d "${EXTRACTED}" ] | |
then | |
# Check if already downloaded | |
if [ ! -f "${TMP_FILE}" ] | |
then | |
echo "Downloading to ${TMP_FILE}" | |
curl -L --progress-bar -o "${TMP_FILE}" "${URL}" | |
fi | |
echo "Extracting..." | |
tar zxf ${TMP_FILE} -C ${TMP_DIR} | |
rm ${TMP_FILE} | |
fi | |
echo "Installing to ${INSTALL_DIR}" | |
if [ -d "${INSTALL_DIR}" ] | |
then | |
rm -rf ${INSTALL_DIR} | |
fi | |
mv $(echo ${EXTRACTED}) "${INSTALL_DIR}/" | |
echo "Cleanup..." | |
rm -rf "${TMP_DIR}" | |
echo "Done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
similar script for install or update(auto) jetbrains products like phpstorm, webstorm, IntelliJ Idea and other. + dependencies + non latin hotkeys fixes
https://gist.github.com/zabidok/8418c4f679741f585ac9ce90b16fb8a5