Skip to content

Instantly share code, notes, and snippets.

@Atalanta
Created December 2, 2010 19:08
Show Gist options
  • Save Atalanta/725865 to your computer and use it in GitHub Desktop.
Save Atalanta/725865 to your computer and use it in GitHub Desktop.
include_recipe "git"
user "git" do
comment "Git User"
home "/srv/git"
end
directory "/srv/git" do
owner "git"
group "git"
end
directory "/srv/git/.ssh" do
owner "git"
group "git"
mode "0700"
end
keys = []
search(:users, "git_key:*").each do |user|
keys << user[:git_key]
end
template "/srv/git/.ssh/authorized_keys" do
source "authorized_keys.erb"
owner "git"
group "git"
mode "0600"
variables :git_keys => keys
end
search(:git_repos, "*:*").each do |repo|
repo_path = "/srv/git/#{repo[:id]}.git"
directory repo_path do
owner "git"
group "git"
mode "2775"
end
execute "initialize new shared git repo" do
command "cd #{repo_path} && git --bare init --shared"
only_if { !File.exists? "#{repo_path}/HEAD" }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment