Skip to content

Instantly share code, notes, and snippets.

@sndsgd
Last active August 29, 2015 14:02
Show Gist options
  • Save sndsgd/a1e6341bc0df8b68c92a to your computer and use it in GitHub Desktop.
Save sndsgd/a1e6341bc0df8b68c92a to your computer and use it in GitHub Desktop.
Update Google Closure Tools
#!/bin/bash
GOOG_LIB_DIR=/usr/lib/google/closure
TMP_DIR=/tmp/update-google-closure-tools
if [ "$UID" -ne 0 ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
if [[ ! -d $GOOG_LIB_DIR ]]; then
mkdir -p $GOOG_LIB_DIR
fi
if [[ ! -d $TMP_DIR ]]; then
mkdir -p $TMP_DIR
fi
# download and copy the compiler
wget -O $TMP_DIR/compiler.zip \
http://dl.google.com/closure-compiler/compiler-latest.zip
if [[ ! -f $TMP_DIR/compiler.zip ]]; then
echo "Failed to download compiler archive"
exit 1
fi
unzip $TMP_DIR/compiler.zip -d $TMP_DIR
if [[ ! -f $TMP_DIR/compiler.jar ]]; then
echo "Something went wrong; the compiler.jar file could not be found"
exit 1
fi
mv $TMP_DIR/compiler.jar $GOOG_LIB_DIR/compiler.jar
chown root:root $GOOG_LIB_DIR/compiler.jar
chmod 664 $GOOG_LIB_DIR/compiler.jar
# cleanup
rm -rf $TMP_DIR
if [[ -d $GOOG_LIB_DIR/library && -d $GOOG_LIB_DIR/library/.git ]]; then
echo 'updating closure-library git repo'
git --git-dir=$GOOG_LIB_DIR/library/.git --work-tree=$GOOG_LIB_DIR/library/ pull
else
echo 'cloing closure-library git repo'
git clone \
--depth=1 \
https://github.com/google/closure-library $GOOG_LIB_DIR/library
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment