Skip to content

Instantly share code, notes, and snippets.

@pencil
Forked from raggi/validate_local_cache.sh
Last active December 11, 2015 23:39
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save pencil/4678250 to your computer and use it in GitHub Desktop.
Save pencil/4678250 to your computer and use it in GitHub Desktop.
#!/usr/bin/env sh
if ! which md5sum > /dev/null; then
echo Install md5sum
exit 1
fi
if ! which curl > /dev/null; then
echo Install curl
exit 1
fi
echo This will take a while...
for x in ~/.rvm/gems/*; do
home=$x
cache=$home/cache
if [ -d $cache ]
then
for gem in $cache/*.gem; do
gemfile=$(basename $gem)
local=$(md5sum $gem | awk '{print $1}')
remote=$(curl -s -D - -X HEAD -H 'Connection:close' http://production.cf.rubygems.org/gems/$gemfile | grep 'ETag' | cut -d '"' -f 2)
if [[ ! $local = $remote ]]; then
echo $gemfile mismatch. local: $local, remote: $remote
fi
done
fi
done
echo All done.
#!/usr/bin/env sh
if ! which openssl > /dev/null; then
echo Install openssl
exit 1
fi
if ! which curl > /dev/null; then
echo Install curl
exit 1
fi
echo This will take a while...
for x in ~/.rvm/gems/*; do
home=$x
cache=$home/cache
if [ -d $cache ]
then
for gem in $cache/*.gem; do
gemfile=$(basename $gem)
local=$(openssl md5 $gem | awk '{print $2}')
remote=$(curl -s -D - -X HEAD -H 'Connection:close' http://production.cf.rubygems.org/gems/$gemfile | grep 'ETag' | cut -d '"' -f 2)
if [[ ! $local = $remote ]]; then
echo $gemfile mismatch. local: $local, remote: $remote
fi
done
fi
done
echo All done.
@bradpauly
Copy link

You can install md5sum on OS X via brew with brew install md5sha1sum

@reggieb
Copy link

reggieb commented Jan 31, 2013

See this comment on original gist, if you are getting not found errors on ubuntu

https://gist.github.com/4678189#comment-762924

@taq
Copy link

taq commented Jan 31, 2013

Just changed them to check for RVM system wide installs: https://gist.github.com/4682102

@mccraigmccraig
Copy link

here's a version for rbenv gemsets : https://gist.github.com/4682402

@pokkemon
Copy link

In case if you run into

./validate_local_cache_openssl.sh: 31: [[: not found

just run scripts with

bash validate_local_cache_openssl.sh 

@taq
Copy link

taq commented Jan 31, 2013

On my change I changed from #!/usr/bin/env sh to #!/bin/bash to explicit call bash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment