@@ -24,6 +24,7 @@ restart restart the web server
2424fqgitdir=" $GIT_DIR "
2525local=" $( git config --bool --get instaweb.local) "
2626httpd=" $( git config --get instaweb.httpd) "
27+ root=" $( git config --get instaweb.gitwebdir) "
2728port=$( git config --get instaweb.port)
2829module_path=" $( git config --get instaweb.modulepath) "
2930
@@ -34,6 +35,9 @@ conf="$GIT_DIR/gitweb/httpd.conf"
3435# if installed, it doesn't need further configuration (module_path)
3536test -z " $httpd " && httpd=' lighttpd -f'
3637
38+ # Default is @@GITWEBDIR@@
39+ test -z " $root " && root=' @@GITWEBDIR@@'
40+
3741# any untaken local port will do...
3842test -z " $port " && port=1234
3943
@@ -57,7 +61,7 @@ resolve_full_httpd () {
5761 # these days and those are not in most users $PATHs
5862 # in addition, we may have generated a server script
5963 # in $fqgitdir/gitweb.
60- for i in /usr/local/sbin /usr/sbin " $fqgitdir /gitweb"
64+ for i in /usr/local/sbin /usr/sbin " $root " " $ fqgitdir /gitweb"
6165 do
6266 if test -x " $i /$httpd_only "
6367 then
159163mkdir -p " $GIT_DIR /gitweb/tmp"
160164GIT_EXEC_PATH=" $( git --exec-path) "
161165GIT_DIR=" $fqgitdir "
162- export GIT_EXEC_PATH GIT_DIR
163-
166+ GITWEB_CONFIG= " $fqgitdir /gitweb/gitweb_config.perl "
167+ export GIT_EXEC_PATH GIT_DIR GITWEB_CONFIG
164168
165169webrick_conf () {
166170 # generate a standalone server script in $fqgitdir/gitweb.
192196
193197 cat > " $conf " << EOF
194198:Port: $port
195- :DocumentRoot: "$fqgitdir /gitweb "
199+ :DocumentRoot: "$root "
196200:DirectoryIndex: ["gitweb.cgi"]
197201:PidFile: "$fqgitdir /pid"
198202EOF
201205
202206lighttpd_conf () {
203207 cat > " $conf " << EOF
204- server.document-root = "$fqgitdir /gitweb "
208+ server.document-root = "$root "
205209server.port = $port
206210server.modules = ( "mod_setenv", "mod_cgi" )
207211server.indexfiles = ( "gitweb.cgi" )
@@ -212,7 +216,7 @@ server.errorlog = "$fqgitdir/gitweb/$httpd_only/error.log"
212216# variable above and uncomment this
213217#accesslog.filename = "$fqgitdir /gitweb/$httpd_only /access.log"
214218
215- setenv.add-environment = ( "PATH" => env.PATH )
219+ setenv.add-environment = ( "PATH" => env.PATH, "GITWEB_CONFIG" => env.GITWEB_CONFIG )
216220
217221cgi.assign = ( ".cgi" => "" )
218222
@@ -282,8 +286,8 @@ apache2_conf () {
282286 echo ' text/css css' > " $fqgitdir /mime.types"
283287 cat > " $conf " << EOF
284288ServerName "git-instaweb"
285- ServerRoot "$fqgitdir /gitweb "
286- DocumentRoot "$fqgitdir /gitweb "
289+ ServerRoot "$root "
290+ DocumentRoot "$root "
287291ErrorLog "$fqgitdir /gitweb/$httpd_only /error.log"
288292CustomLog "$fqgitdir /gitweb/$httpd_only /access.log" combined
289293PidFile "$fqgitdir /pid"
@@ -304,13 +308,14 @@ EOF
304308 # check to see if Dennis Stosberg's mod_perl compatibility patch
305309 # (<20060621130708.Gcbc6e5c@leonov.stosberg.net>) has been applied
306310 if test -f " $module_path /mod_perl.so" &&
307- sane_grep ' MOD_PERL' " $GIT_DIR /gitweb /gitweb.cgi" > /dev/null
311+ sane_grep ' MOD_PERL' " $root /gitweb.cgi" > /dev/null
308312 then
309313 # favor mod_perl if available
310314 cat >> " $conf " << EOF
311315LoadModule perl_module $module_path /mod_perl.so
312316PerlPassEnv GIT_DIR
313317PerlPassEnv GIT_EXEC_DIR
318+ PerlPassEnv GITWEB_CONFIG
314319<Location /gitweb.cgi>
315320 SetHandler perl-script
316321 PerlResponseHandler ModPerl::Registry
@@ -354,15 +359,15 @@ mongoose_conf() {
354359# For detailed description of every option, visit
355360# http://code.google.com/p/mongoose/wiki/MongooseManual
356361
357- root $fqgitdir /gitweb
362+ root $root
358363ports $port
359364index_files gitweb.cgi
360365#ssl_cert $fqgitdir /gitweb/ssl_cert.pem
361366error_log $fqgitdir /gitweb/$httpd_only /error.log
362367access_log $fqgitdir /gitweb/$httpd_only /access.log
363368
364369#cgi setup
365- cgi_env PATH=$PATH ,GIT_DIR=$GIT_DIR ,GIT_EXEC_PATH=$GIT_EXEC_PATH
370+ cgi_env PATH=$PATH ,GIT_DIR=$GIT_DIR ,GIT_EXEC_PATH=$GIT_EXEC_PATH ,GITWEB_CONFIG= $GITWEB_CONFIG
366371cgi_interp $PERL
367372cgi_ext cgi,pl
368373
@@ -371,41 +376,16 @@ mime_types .gz=application/x-gzip,.tar.gz=application/x-tgz,.tgz=application/x-t
371376EOF
372377}
373378
374-
375- script='
376- s#^(my|our) \$projectroot =.*#$1 \$projectroot = "' $( dirname " $fqgitdir " ) ' ";#;
377- s#(my|our) \$gitbin =.*#$1 \$gitbin = "' $GIT_EXEC_PATH ' ";#;
378- s#(my|our) \$projects_list =.*#$1 \$projects_list = \$projectroot;#;
379- s#(my|our) \$git_temp =.*#$1 \$git_temp = "' $fqgitdir /gitweb/tmp' ";#;'
380-
381- gitweb_cgi () {
382- cat > " $1 .tmp" << \EOFGITWEB
383- @@GITWEB_CGI@@
384- EOFGITWEB
385- # Use the configured full path to perl to match the generated
386- # scripts' 'hashpling' line
387- " $PERL " -p -e " $script " " $1 .tmp" > " $1 "
388- chmod +x " $1 "
389- rm -f " $1 .tmp"
390- }
391-
392- gitweb_css () {
393- cat > " $1 " << \EOFGITWEB
394- @@GITWEB_CSS@@
395-
396- EOFGITWEB
397- }
398-
399- gitweb_js () {
400- cat > " $1 " << \EOFGITWEB
401- @@GITWEB_JS@@
402-
403- EOFGITWEB
379+ gitweb_conf () {
380+ cat > " $fqgitdir /gitweb/gitweb_config.perl" << EOF
381+ #!/usr/bin/perl
382+ our \$ projectroot = "$( dirname " $fqgitdir " ) ";
383+ our \$ git_temp = "$fqgitdir /gitweb/tmp";
384+ our \$ projects_list = \$ projectroot;
385+ EOF
404386}
405387
406- gitweb_cgi " $GIT_DIR /gitweb/gitweb.cgi"
407- gitweb_css " $GIT_DIR /@@GITWEB_CSS_NAME@@"
408- gitweb_js " $GIT_DIR /@@GITWEB_JS_NAME@@"
388+ gitweb_conf
409389
410390resolve_full_httpd
411391mkdir -p " $fqgitdir /gitweb/$httpd_only "
0 commit comments