Last active
November 4, 2015 14:45
-
-
Save Rondom/b40af5c4d33f95c498db to your computer and use it in GitHub Desktop.
Downloads clion to /tmp and extracts it. Can be used to circumwent tight disk quotas in home-dirs
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 | |
SCRIPTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd )" | |
WORKDIR="$SCRIPTDIR/files" | |
TARURL="https://download.jetbrains.com/cpp/clion-1.2.tar.gz" | |
HASHURL="${TARURL}.sha256" | |
TARPATH="$WORKDIR/clion.tar.gz" | |
EXTRACTDIR="$WORKDIR" | |
if [ ! -d "$WORKDIR" ]; then | |
rm "$WORKDIR" | |
ln -s "$(mktemp --suffix .cliondl -d)" "$WORKDIR" | |
echo Created new temporary directory symlink $WORKDIR | |
fi | |
DESIREDHASH=$(wget -q "$HASHURL" -O - | awk '{ print $1 }') | |
ACTUALHASH=$(sha256sum "$TARPATH" | awk '{ print $1 }') | |
# Assuming that an existing tar with the right hash means an extracted tar | |
if [ ! -f "$TARPATH" -o "$DESIREDHASH" != "$ACTUALHASH" ]; then | |
echo Did not find existing file, downloading... | |
wget -nv "$TARURL" -O "$TARPATH" | |
echo Extracting $TARPATH to $EXTRACTDIR | |
tar xzf "$TARPATH" --directory="$EXTRACTDIR" || (rm -rf "$EXTRACDIR"; rm -r "$TARPATH") | |
fi | |
$EXTRACTDIR/clion*/bin/clion.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment