@@ -24,6 +24,7 @@ restart restart the web server
24
24
fqgitdir=" $GIT_DIR "
25
25
local=" $( git config --bool --get instaweb.local) "
26
26
httpd=" $( git config --get instaweb.httpd) "
27
+ root=" $( git config --get instaweb.gitwebdir) "
27
28
port=$( git config --get instaweb.port)
28
29
module_path=" $( git config --get instaweb.modulepath) "
29
30
@@ -34,6 +35,9 @@ conf="$GIT_DIR/gitweb/httpd.conf"
34
35
# if installed, it doesn't need further configuration (module_path)
35
36
test -z " $httpd " && httpd=' lighttpd -f'
36
37
38
+ # Default is @@GITWEBDIR@@
39
+ test -z " $root " && root=' @@GITWEBDIR@@'
40
+
37
41
# any untaken local port will do...
38
42
test -z " $port " && port=1234
39
43
@@ -57,7 +61,7 @@ resolve_full_httpd () {
57
61
# these days and those are not in most users $PATHs
58
62
# in addition, we may have generated a server script
59
63
# 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"
61
65
do
62
66
if test -x " $i /$httpd_only "
63
67
then
159
163
mkdir -p " $GIT_DIR /gitweb/tmp"
160
164
GIT_EXEC_PATH=" $( git --exec-path) "
161
165
GIT_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
164
168
165
169
webrick_conf () {
166
170
# generate a standalone server script in $fqgitdir/gitweb.
192
196
193
197
cat > " $conf " << EOF
194
198
:Port: $port
195
- :DocumentRoot: "$fqgitdir /gitweb "
199
+ :DocumentRoot: "$root "
196
200
:DirectoryIndex: ["gitweb.cgi"]
197
201
:PidFile: "$fqgitdir /pid"
198
202
EOF
201
205
202
206
lighttpd_conf () {
203
207
cat > " $conf " << EOF
204
- server.document-root = "$fqgitdir /gitweb "
208
+ server.document-root = "$root "
205
209
server.port = $port
206
210
server.modules = ( "mod_setenv", "mod_cgi" )
207
211
server.indexfiles = ( "gitweb.cgi" )
@@ -212,7 +216,7 @@ server.errorlog = "$fqgitdir/gitweb/$httpd_only/error.log"
212
216
# variable above and uncomment this
213
217
#accesslog.filename = "$fqgitdir /gitweb/$httpd_only /access.log"
214
218
215
- setenv.add-environment = ( "PATH" => env.PATH )
219
+ setenv.add-environment = ( "PATH" => env.PATH, "GITWEB_CONFIG" => env.GITWEB_CONFIG )
216
220
217
221
cgi.assign = ( ".cgi" => "" )
218
222
@@ -282,8 +286,8 @@ apache2_conf () {
282
286
echo ' text/css css' > " $fqgitdir /mime.types"
283
287
cat > " $conf " << EOF
284
288
ServerName "git-instaweb"
285
- ServerRoot "$fqgitdir /gitweb "
286
- DocumentRoot "$fqgitdir /gitweb "
289
+ ServerRoot "$root "
290
+ DocumentRoot "$root "
287
291
ErrorLog "$fqgitdir /gitweb/$httpd_only /error.log"
288
292
CustomLog "$fqgitdir /gitweb/$httpd_only /access.log" combined
289
293
PidFile "$fqgitdir /pid"
@@ -304,13 +308,14 @@ EOF
304
308
# check to see if Dennis Stosberg's mod_perl compatibility patch
305
309
# (<[email protected] >) has been applied
306
310
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
308
312
then
309
313
# favor mod_perl if available
310
314
cat >> " $conf " << EOF
311
315
LoadModule perl_module $module_path /mod_perl.so
312
316
PerlPassEnv GIT_DIR
313
317
PerlPassEnv GIT_EXEC_DIR
318
+ PerlPassEnv GITWEB_CONFIG
314
319
<Location /gitweb.cgi>
315
320
SetHandler perl-script
316
321
PerlResponseHandler ModPerl::Registry
@@ -354,15 +359,15 @@ mongoose_conf() {
354
359
# For detailed description of every option, visit
355
360
# http://code.google.com/p/mongoose/wiki/MongooseManual
356
361
357
- root $fqgitdir /gitweb
362
+ root $root
358
363
ports $port
359
364
index_files gitweb.cgi
360
365
#ssl_cert $fqgitdir /gitweb/ssl_cert.pem
361
366
error_log $fqgitdir /gitweb/$httpd_only /error.log
362
367
access_log $fqgitdir /gitweb/$httpd_only /access.log
363
368
364
369
#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
366
371
cgi_interp $PERL
367
372
cgi_ext cgi,pl
368
373
@@ -371,41 +376,16 @@ mime_types .gz=application/x-gzip,.tar.gz=application/x-tgz,.tgz=application/x-t
371
376
EOF
372
377
}
373
378
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
404
386
}
405
387
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
409
389
410
390
resolve_full_httpd
411
391
mkdir -p " $fqgitdir /gitweb/$httpd_only "
0 commit comments