Skip to content

Instantly share code, notes, and snippets.

@szajbus
Forked from raggi/validate_local_cache.sh
Last active December 12, 2015 00:18
Show Gist options
  • Save szajbus/4682614 to your computer and use it in GitHub Desktop.
Save szajbus/4682614 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
if ! which openssl > /dev/null; then
echo Install openssl
exit 1
fi
if ! which curl > /dev/null; then
echo Install curl
exit 1
fi
gem_cache=$1
invalid=0
echo This will take a while...
for gem in $gem_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
invalid=1
fi
done
if [[ $invalid = 0 ]]; then
echo All gems are valid.;
else
echo Some gems are invalid.;
fi
exit $invalid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment