Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[COOK-2303] Added RHEL platform_family support to git::server #14

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ To install git server:

include_recipe "git::server"

This creates the directory /srv/git and starts a git daemon, exporting
all repositories found. Repositories need to be added manually, but
will be available once they are created.
This creates the directory specified by git/server/base_path (default is /srv/git)
and starts a git daemon, exporting all repositories found. Repositories need to be
added manually, but will be available once they are created.

License and Author
==================
Expand Down
3 changes: 3 additions & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@
default['git']['url'] = "https://github.com/git/git/tarball/v#{node['git']['version']}"
default['git']['checksum'] = "24f1895fa74a23b3d9233fa89a9ef04d83a1cd952d659720d6ea231bbd0c973c"
end

default['git']['server']['base_path'] = "/srv/git"
default['git']['server']['export_all'] = "true"
13 changes: 13 additions & 0 deletions metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,16 @@
end

depends "runit", "<= 0.16.2"

attribute "git/server/base_path",
:display_name => "Git Daemon Base Path",
:description => "A directory containing git repositories to be exposed by the git-daemon",
:default => "/srv/git",
:recipes => ["git::server"]

attribute "git/server/export_all",
:display_name => "Git Daemon Export All",
:description => "Adds the --export-all option to the git-daemon parameters, making all repositories publicly readable even if they lack the \"git-daemon-export-ok\" file",
:choice => ["true", "false"],
:default => "true",
:recipes => ["git::server"]
21 changes: 19 additions & 2 deletions recipes/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

include_recipe "git"

directory "/srv/git" do
directory node["git"]["server"]["base_path"] do
owner "root"
group "root"
mode 00755
Expand All @@ -31,8 +31,25 @@
case node['platform_family']
when "debian"
include_recipe "runit"

package "git-daemon-run"

runit_service "git-daemon"
when "rhel"
package "git-daemon"

template "/etc/xinetd.d/git" do
backup false
source "git-xinetd.d.erb"
owner "root"
group "root"
mode 00644
end

service "xinetd" do
action [:enable, :restart]
end
else
log "Platform requires setting up a git daemon service script."
log "Hint: /usr/bin/git daemon --export-all --user=nobody --group=daemon --base-path=/srv/git"
log "Hint: /usr/bin/git daemon --export-all --user=nobody --group=daemon --base-path=#{node["git"]["server"]["base_path"]}"
end
10 changes: 10 additions & 0 deletions templates/default/git-xinetd.d.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
service git
{
disable = no
socket_type = stream
wait = no
user = nobody
server = /usr/libexec/git-core/git-daemon
server_args = --base-path=<%= node["git"]["server"]["base_path"] %> <% if node["git"]["server"]["export_all"] == "true" %>--export-all <% end %>--syslog --inetd --verbose
log_on_failure += USERID
}
2 changes: 1 addition & 1 deletion templates/default/sv-git-daemon-run.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh
exec 2>&1
exec /usr/bin/git daemon --export-all --user=nobody --group=daemon --base-path=/srv/git /srv/git
exec /usr/bin/git daemon <% if node["git"]["server"]["export_all"] == "true" %>--export-all <% end %>--user=nobody --group=daemon --syslog --base-path=<%= node["git"]["server"]["base_path"] %> <%= node["git"]["server"]["base_path"] %>