Last active
August 29, 2015 14:22
-
-
Save skatsuta/8f63194dfd65712da640 to your computer and use it in GitHub Desktop.
Script for storing / restoring cache in Java / Scala project on wercker
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 | |
#========================================= | |
# 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