Created
April 3, 2013 01:53
-
-
Save jssjr/5297836 to your computer and use it in GitHub Desktop.
Vbox Snapshot looper
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
#autoload | |
vsnap() { | |
trap "exit 1" INT | |
if [[ $#@ -ne 2 ]] ; then | |
echo 'usage: vsnap VM_NAME SNAPSHOT_DIR' | |
return 1 | |
fi | |
lastsnap="0" | |
mkdir -p $2 | |
while true ; do | |
F=$(mktemp /tmp/vsnap.XXXXXX) | |
bundle exec vagrant basebox screenshot $1 $F | |
cursnap=$(md5 -q $F) | |
if [ "$cursnap" = "$lastsnap" ] ; then | |
echo 'skipping identical snap' | |
rm -f $F | |
else | |
lastsnap=$cursnap | |
mv $F $2/vsnap-$(date +%s)-$((counter++)).png | |
rm -f $F | |
fi | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment