Skip to content

Instantly share code, notes, and snippets.

@jssjr
Created November 20, 2012 17: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 jssjr/4119386 to your computer and use it in GitHub Desktop.
Save jssjr/4119386 to your computer and use it in GitHub Desktop.
Mirror the opscode-cookbook repos
#!/usr/bin/env sh
### Mirror all of the opscode-cookbooks repositories
trap "exit 1" INT TERM # exit gracefully if we're in the main loop
repos=$(curl -s -o- https://api.github.com/users/opscode-cookbooks/repos\?per_page\=1000 \
| ruby -rubygems -e 'require "json"; JSON.load(STDIN.read).each{|r| puts r["git_url"]}')
for repo in $repos ; do
repo_name=$(echo "$repo" | sed -e 's#^.*/\([^.]*\).git$#\1#')
echo "> $repo_name"
if [ -d "$repo_name" ] ; then
( cd "$repo_name" ; git pull )
else
git clone "$repo"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment