threads / discuss / 675

add conf file support to gitweb

Subject: add conf file support to gitweb

## tl;dr

One message between May 20, 2005 and May 20, 2005.

replies: 0people: 1as markdown or json

Andres Salomon· May 20, 2005, 19:29 UTC · lore
Hi,

The attached patch makes gitweb read and eval variables from an /etc/gitweb.conf file. This is useful for distributions; I'm packaging gitweb for debian, and want to have a separate config file that users can edit that won't get overwritten when they upgrade gitweb. Even if you don't take this patch, please consider some other method that decouples the configuration from the gitweb.cgi script.

Index: gitweb.cgi
===================================================================
--- 8b7a4b08ba4892970a2531d4c1584e3881a13586/gitweb.cgi  (mode:100644)
+++ fe8329b147103e115e2ad727bfca34c2ecfa901d/gitweb.cgi  (mode:100755)
@@ -40,6 +40,16 @@
 #my $projects_list = $projectroot;
 my $projects_list = "index/index.aux";
 
+# allow config file to override settings above
+if (-r '/etc/gitweb.conf') {
+	open(CONF, '/etc/gitweb.conf') || die_error(undef, "Cannot open /etc/gitweb.conf.");
+	while (<CONF>) {
+		chomp;
+		eval($_) if ($_ =~ /^\s*(\$[\w]+)\s*=\s*(.*)\s*$/);
+	}
+	close(CONF);
+}
+
 # input validation and dispatch
 my $action = $cgi->param('a');
 if (defined $action) {

← back to recent threads