From f920efab5fd5f0bf0b55a4b555226ef741415835 Mon Sep 17 00:00:00 2001
From: Todd Zullinger <tmz@pobox.com>
Date: Fri, 8 Apr 2011 17:17:28 -0400
Subject: [PATCH 2/2] gitweb-caching: Use /etc/gitweb.conf for modified config

Overriding /var/www/gitweb-caching/gitweb_defaults.pl is less than
ideal.  For one, it's a much larger file to wade through when looking to
check our local changes.  It's also not marked as a config file, so rpm
updates will overrite it.  (Sure, puppet will come along and fix that
within 30 minutes, but we can avoid that potential delay entirely by
using /etc/gitweb.conf.)
---
 modules/gitweb-caching/manifests/init.pp         |   12 ++--
 modules/gitweb-caching/templates/gitweb.conf.erb |   72 ++++++++++++++++++++++
 2 files changed, 78 insertions(+), 6 deletions(-)
 create mode 100644 modules/gitweb-caching/templates/gitweb.conf.erb

diff --git a/modules/gitweb-caching/manifests/init.pp b/modules/gitweb-caching/manifests/init.pp
index 4ed4a13..65d11b2 100644
--- a/modules/gitweb-caching/manifests/init.pp
+++ b/modules/gitweb-caching/manifests/init.pp
@@ -20,15 +20,15 @@ define gitweb-caching::gitweb-caching (
 
     $site_name = $name
 
+    file { '/etc/gitweb.conf':
+        content => template('gitweb-caching/gitweb.conf.erb'),
+        require => Package['gitweb-caching']
+    }
+
     file { '/etc/httpd/conf.d/gitweb-caching.conf':
         content => template('gitweb-caching/gitweb.httpd.erb'),
         require => Package['httpd'],
-        notify => Service['httpd'],
-    }
-    
-    file { '/var/www/gitweb-caching/gitweb_defaults.pl':
-        content => template('gitweb-caching/gitweb_defaults.pl.erb'),
-        require => Package['gitweb-caching']
+        notify  => Service['httpd'],
     }
 
     file { '/srv/gitweb-cache':
diff --git a/modules/gitweb-caching/templates/gitweb.conf.erb b/modules/gitweb-caching/templates/gitweb.conf.erb
new file mode 100644
index 0000000..30568d8
--- /dev/null
+++ b/modules/gitweb-caching/templates/gitweb.conf.erb
@@ -0,0 +1,72 @@
+# The gitweb config file is a fragment of perl code. You can set variables using
+# "our $variable = value"; text from "#" character until the end of a line is
+# ignored. See perlsyn(1) man page for details.
+#
+# Refer to /usr/share/doc/gitweb-caching-*/README and
+# /var/www/gitweb-caching/gitweb_defaults.pl for more details and available
+# configuration variables.
+
+# core git executable to use
+# this can just be "git" if your webserver has a sensible PATH
+$GIT = "<%= git_path -%>";
+
+# absolute fs-path which will be prepended to the project path
+#our $projectroot = "/pub/scm";
+$projectroot = "<%= projectroot -%>";
+
+# fs traversing limit for getting project list
+# the number is relative to the projectroot
+$project_maxdepth = <%= project_maxdepth -%>;
+
+# name of your site or organization to appear in page titles
+# replace this with something more descriptive for clearer bookmarks
+$site_name = "<%= site_name %>";
+
+# URI of stylesheets
+@stylesheets = ("/gitweb/gitweb.css");
+# URI of a single stylesheet, which can be overridden in GITWEB_CONFIG.
+$stylesheet = undef;
+# URI of GIT logo (72x27 size)
+$logo = "<%= logo -%>";
+# URI of GIT favicon, assumed to be image/png type
+$favicon = "<%= favicon -%>";
+# URI of gitweb.js (JavaScript code for gitweb)
+$javascript = "/gitweb/gitweb.js";
+
+# URI and label (title) of GIT logo link
+$logo_url = "<%= logo_url -%>";
+$logo_label = "<%= logo_label -%>";
+
+# list of git base URLs used for URL to where fetch project from,
+# i.e. full URL is "$git_base_url/$project"
+our @git_base_url_list = (<%= git_base_url_list -%>);
+
+# assume this charset if line contains non-UTF-8 characters;
+# it should be valid encoding (see Encoding::Supported(3pm) for list),
+# for which encoding all byte sequences are valid, for example
+# 'iso-8859-1' aka 'latin1' (it is decoded without checking, so it
+# could be even 'utf-8' for the old behavior)
+$fallback_encoding = 'utf-8';
+
+# Used to set the maximum load that we will still respond to gitweb queries.
+# if we exceed this than we do the processing to figure out if there's a mirror
+# and redirect to it, or to just return 503 server busy
+$maxload = 30;
+
+# This enables/disables the caching layer in gitweb.  This currently only supports the
+# 'dumb' file based caching layer, primarily used on git.kernel.org.  this is reasonably
+# effective but it has the downside of requiring a huge amount of disk space if there
+# are a number of repositories involved.  It is not uncommon for git.kernel.org to have
+# on the order of 80G - 120G accumulate over the course of a few months.  It is recommended
+# that the cache directory be periodically completely deleted, and this is safe to perform.
+# Suggested mechanism
+# mv $cacheidr $cachedir.flush;mkdir $cachedir;rm -rf $cachedir.flush
+# Value is binary. 0 = disabled (default), 1 = enabled.
+$cache_enable = 1;
+
+# If you need to change the location of the caching directory, override this
+# otherwise this will probably do fine for you
+$cachedir = '/srv/gitweb-cache';
+
+# Disable Snapshots
+$feature{'snapshot'}{'default'} = [];
-- 
1.7.4.4

