Skip to content

Instantly share code, notes, and snippets.

@jacekjk
Forked from mslinn/installActivator.sh
Last active March 11, 2016 00:07
Show Gist options
  • Save jacekjk/25213afed89267839f39 to your computer and use it in GitHub Desktop.
Save jacekjk/25213afed89267839f39 to your computer and use it in GitHub Desktop.
Installs Typesafe Activator on Ubuntu. Requires jq (https://stedolan.github.io/jq/)
#!/bin/bash
# Forked from Mike Slinn's Gist
# changed to use jq instead of grep for json parsing, updated file names, removed CygWin/Linux distinction (just run with sudo)
set -eo pipefail
function help {
echo "Download or update Typesafe Activator on Linux
echo "Usage: $(basename $0) [options]"
echo "Options are:"
echo " -m Download minimal version (without prepackaged dependencies)"
exit -1
}
# This installs Activator into /opt/activator-x.yy. You can change the root of the installation directory by modifying the next line:
DEST=/opt
QUIET="-q"
MINMAX=maximum
if [ "$1" == "-m" ]; then
MINMAX=minimal
shift
echo "Fetching minimal version of Activator (without prepackaged dependencies)"
fi
if [ "$1" ]; then help; fi
function GET_VERSION {
# Typical return value: 1.2.10
echo "$(echo "$1" | sed -re 's^.*?/([0-9.]+)/.*?^\1^')"
}
function SETUP {
if [ "$MINMAX" == minimal ]; then
# Typesafe maintains the current version information for Activator at this URL:
DL="$(wget --no-check-certificate -qO -P ./ https://activator-prod.herokuapp.com/latest | jq -r '.miniUrl')"
# Typical value for DL is http://downloads.typesafe.com/typesafe-activator/1.3.5/typesafe-activator-1.3.5-minimal.zip
AVER="$(GET_VERSION $DL)"
ADIR=activator-$AVER-minimal
AZIP=typesafe-activator-$AVER-minimal.zip
else
DL="$(wget --no-check-certificate -qO -P ./ https://activator-prod.herokuapp.com/latest | jq -r '.url')"
# Typical value for DL is http://downloads.typesafe.com/typesafe-activator/1.3.5/typesafe-activator-1.3.5.zip
AVER="$(GET_VERSION $DL)"
ADIR=activator-$AVER-minimal
AZIP=typesafe-activator-$AVER-minimal.zip
fi
}
function UNZIP {
if [ -f "$AZIP" ]; then
echo "$PWD/$AZIP already exists, not downloading it again."
else
wget -O $AZIP http://downloads.typesafe.com/typesafe-activator/$AVER/$AZIP
fi
if [ -d "$ADIR" ]; then
echo "$PWD/$ADIR already exists, not unzipping again."
else
unzip -o $QUIET $AZIP
#rm $AZIP
fi
}
SETUP
DESTPATH="$DEST/activator-$AVER"
if [ -d "$DESTPATH" ]; then
echo "Activator $AVER not unzipped because $DESTPATH already exists"
echo "$DESTPATH already exists, not moved into place"
else
UNZIP
mv $ADIR $DESTPATH
#rm -rf activator-$AVER
fi
mkdir -p ~/.activator
ACFG=~/.activator/activatorconfig.txt
if [ -f "$ACFG" ]; then
if [ -z "$(grep 'Dhttp.nonProxyHost' $ACFG)" ]; then
echo '-Dhttp.nonProxyHost="localhost|127.0.0.1"' >> "$ACFG"
fi
else
echo '-Dhttp.nonProxyHost="localhost|127.0.0.1"' >> "$ACFG"
fi
# If activator is not on the path, create link to /usr/local/bin/activator (and the jar that actually contains Activator) so you can simply type 'activator' to run it
if [ -z "$(which activator)" ]; then
ln "$DESTPATH/activator" /usr/local/bin/activator
ln "$DESTPATH/activator-launch-$AVER.jar" /usr/local/bin/activator-launch-$AVER.jar
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment