Skip to content

Instantly share code, notes, and snippets.

@skatsuta
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skatsuta/8f63194dfd65712da640 to your computer and use it in GitHub Desktop.
Save skatsuta/8f63194dfd65712da640 to your computer and use it in GitHub Desktop.
Script for storing / restoring cache in Java / Scala project on wercker
#!/bin/bash
#=========================================
# Script for storing and restoring cache
# in Java / Scala project on werkcer
#=========================================
# cache directories
CACHES=( "ivy2" "sbt" )
CMD="$1"
# check if rsync exists
if ! type rsync > /dev/null; then
echo "[ERROR] rsync needs to be installed."
exit 1
fi
# set source and destination directories
case $CMD in
"store")
SRC=$HOME
DST=$WERCKER_CACHE_DIR
;;
"restore")
SRC=$WERCKER_CACHE_DIR
DST=$HOME
;;
esac
# run rsync
for cache in "${CACHES[@]}"; do
if test -d $SRC/.$cache; then
rsync -avz $SRC/.$cache $DST/
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment