instaweb: minimize moving parts for WEBrick
[git/git.git] / git-instaweb.sh
CommitLineData
a51d37c1
EW
1#!/bin/sh
2#
3# Copyright (c) 2006 Eric Wong
4#
c2db2e0e 5
c5699693 6PERL='@@PERL@@'
c2db2e0e
PH
7OPTIONS_KEEPDASHDASH=
8OPTIONS_SPEC="\
1b1dd23f 9git instaweb [options] (--start | --stop | --restart)
c2db2e0e
PH
10--
11l,local only bind on 127.0.0.1
12p,port= the port to bind to
13d,httpd= the command to launch
14b,browser= the browser to launch
15m,module-path= the module path (only needed for apache2)
16 Action
17stop stop the web server
18start start the web server
19restart restart the web server
20"
a51d37c1
EW
21
22. git-sh-setup
23
b2bc9a30 24fqgitdir="$GIT_DIR"
43d60d2e
FP
25local="$(git config --bool --get instaweb.local)"
26httpd="$(git config --get instaweb.httpd)"
c0cb4ed3 27root="$(git config --get instaweb.gitwebdir)"
43d60d2e
FP
28port=$(git config --get instaweb.port)
29module_path="$(git config --get instaweb.modulepath)"
a51d37c1 30
9126425d 31conf="$GIT_DIR/gitweb/httpd.conf"
a51d37c1
EW
32
33# Defaults:
34
82e5a82f 35# if installed, it doesn't need further configuration (module_path)
a51d37c1
EW
36test -z "$httpd" && httpd='lighttpd -f'
37
c0cb4ed3
PKS
38# Default is @@GITWEBDIR@@
39test -z "$root" && root='@@GITWEBDIR@@'
40
a51d37c1
EW
41# any untaken local port will do...
42test -z "$port" && port=1234
43
43d60d2e
FP
44resolve_full_httpd () {
45 case "$httpd" in
4bdf8599
DM
46 *apache2*|*lighttpd*|*httpd*)
47 # yes, *httpd* covers *lighttpd* above, but it is there for clarity
43d60d2e 48 # ensure that the apache2/lighttpd command ends with "-f"
e1622bfc 49 if ! echo "$httpd" | sane_grep -- '-f *$' >/dev/null 2>&1
43d60d2e
FP
50 then
51 httpd="$httpd -f"
52 fi
53 ;;
78646987
JN
54 *plackup*)
55 # server is started by running via generated gitweb.psgi in $fqgitdir/gitweb
56 full_httpd="$fqgitdir/gitweb/gitweb.psgi"
57 httpd_only="${httpd%% *}" # cut on first space
58 return
59 ;;
422bff28 60 *webrick*)
f46e1304 61 # server is started by running via generated webrick.rb in
422bff28 62 # $fqgitdir/gitweb
f46e1304 63 full_httpd="$fqgitdir/gitweb/webrick.rb"
422bff28
EW
64 httpd_only="${httpd%% *}" # cut on first space
65 return
66 ;;
43d60d2e
FP
67 esac
68
69 httpd_only="$(echo $httpd | cut -f1 -d' ')"
e47eec8f 70 if case "$httpd_only" in /*) : ;; *) which $httpd_only >/dev/null 2>&1;; esac
a51d37c1 71 then
43d60d2e 72 full_httpd=$httpd
a51d37c1
EW
73 else
74 # many httpds are installed in /usr/sbin or /usr/local/sbin
75 # these days and those are not in most users $PATHs
14b45b66
MD
76 # in addition, we may have generated a server script
77 # in $fqgitdir/gitweb.
c0cb4ed3 78 for i in /usr/local/sbin /usr/sbin "$root" "$fqgitdir/gitweb"
a51d37c1
EW
79 do
80 if test -x "$i/$httpd_only"
81 then
43d60d2e 82 full_httpd=$i/$httpd
a51d37c1
EW
83 return
84 fi
85 done
43d60d2e
FP
86
87 echo >&2 "$httpd_only not found. Install $httpd_only or use" \
88 "--httpd to specify another httpd daemon."
f281e3a1 89 exit 1
a51d37c1 90 fi
43d60d2e
FP
91}
92
93start_httpd () {
0b624b4c
SB
94 if test -f "$fqgitdir/pid"; then
95 say "Instance already running. Restarting..."
96 stop_httpd
97 fi
98
43d60d2e
FP
99 # here $httpd should have a meaningful value
100 resolve_full_httpd
101
102 # don't quote $full_httpd, there can be arguments to it (-f)
0ded4758 103 case "$httpd" in
78646987
JN
104 *mongoose*|*plackup*)
105 #These servers don't have a daemon mode so we'll have to fork it
0ded4758
WL
106 $full_httpd "$fqgitdir/gitweb/httpd.conf" &
107 #Save the pid before doing anything else (we'll print it later)
108 pid=$!
109
110 if test $? != 0; then
111 echo "Could not execute http daemon $httpd."
112 exit 1
113 fi
114
115 cat > "$fqgitdir/pid" <<EOF
116$pid
117EOF
118 ;;
119 *)
120 $full_httpd "$fqgitdir/gitweb/httpd.conf"
121 if test $? != 0; then
122 echo "Could not execute http daemon $httpd."
123 exit 1
124 fi
125 ;;
126 esac
a51d37c1
EW
127}
128
129stop_httpd () {
43d60d2e 130 test -f "$fqgitdir/pid" && kill $(cat "$fqgitdir/pid")
d1127622 131 rm -f "$fqgitdir/pid"
a51d37c1
EW
132}
133
d94775e1
JN
134httpd_is_ready () {
135 "$PERL" -MIO::Socket::INET -e "
136local \$| = 1; # turn on autoflush
137exit if (IO::Socket::INET->new('127.0.0.1:$port'));
138print 'Waiting for \'$httpd\' to start ..';
139do {
140 print '.';
141 sleep(1);
142} until (IO::Socket::INET->new('127.0.0.1:$port'));
143print qq! (done)\n!;
144"
145}
146
822f7c73 147while test $# != 0
a51d37c1
EW
148do
149 case "$1" in
150 --stop|stop)
151 stop_httpd
152 exit 0
153 ;;
154 --start|start)
155 start_httpd
156 exit 0
157 ;;
158 --restart|restart)
159 stop_httpd
160 start_httpd
161 exit 0
162 ;;
c2db2e0e 163 -l|--local)
a51d37c1
EW
164 local=true
165 ;;
c2db2e0e
PH
166 -d|--httpd)
167 shift
168 httpd="$1"
169 ;;
170 -b|--browser)
171 shift
172 browser="$1"
a51d37c1 173 ;;
c2db2e0e
PH
174 -p|--port)
175 shift
176 port="$1"
a51d37c1 177 ;;
c2db2e0e
PH
178 -m|--module-path)
179 shift
180 module_path="$1"
a51d37c1 181 ;;
c2db2e0e 182 --)
a51d37c1
EW
183 ;;
184 *)
185 usage
186 ;;
187 esac
188 shift
189done
190
191mkdir -p "$GIT_DIR/gitweb/tmp"
43d60d2e 192GIT_EXEC_PATH="$(git --exec-path)"
a51d37c1 193GIT_DIR="$fqgitdir"
c0cb4ed3
PKS
194GITWEB_CONFIG="$fqgitdir/gitweb/gitweb_config.perl"
195export GIT_EXEC_PATH GIT_DIR GITWEB_CONFIG
a51d37c1 196
425b78e8 197webrick_conf () {
422bff28
EW
198 # webrick seems to have no way of passing arbitrary environment
199 # variables to the underlying CGI executable, so we wrap the
200 # actual gitweb.cgi using a shell script to force it
201 wrapper="$fqgitdir/gitweb/$httpd/wrapper.sh"
202 cat > "$wrapper" <<EOF
203#!/bin/sh
204# we use this shell script wrapper around the real gitweb.cgi since
205# there appears to be no other way to pass arbitrary environment variables
206# into the CGI process
207GIT_EXEC_PATH=$GIT_EXEC_PATH GIT_DIR=$GIT_DIR GITWEB_CONFIG=$GITWEB_CONFIG
208export GIT_EXEC_PATH GIT_DIR GITWEB_CONFIG
209exec $root/gitweb.cgi
210EOF
211 chmod +x "$wrapper"
212
213 # This assumes _ruby_ is in the user's $PATH. that's _one_
214 # portable way to run ruby, which could be installed anywhere, really.
425b78e8
MD
215 # generate a standalone server script in $fqgitdir/gitweb.
216 cat >"$fqgitdir/gitweb/$httpd.rb" <<EOF
f46e1304 217#!/usr/bin/env ruby
425b78e8 218require 'webrick'
f46e1304
EW
219options = {
220 :Port => $port,
221 :DocumentRoot => "$root",
222 :DirectoryIndex => ["gitweb.cgi"],
223 :CGIInterpreter => "$wrapper",
224 :StartCallback => lambda do
225 File.open("$fqgitdir/pid", "w") { |f| f.puts Process.pid }
226 end,
227 :ServerType => WEBrick::Daemon,
228}
229options[:BindAddress] = '127.0.0.1' if "$local" == "true"
425b78e8
MD
230server = WEBrick::HTTPServer.new(options)
231['INT', 'TERM'].each do |signal|
232 trap(signal) {server.shutdown}
233end
234server.start
235EOF
f46e1304
EW
236 chmod +x "$fqgitdir/gitweb/$httpd.rb"
237 # configuration is embedded in server script file, webrick.rb
238 rm -f "$conf"
425b78e8
MD
239}
240
a51d37c1
EW
241lighttpd_conf () {
242 cat > "$conf" <<EOF
c0cb4ed3 243server.document-root = "$root"
a51d37c1 244server.port = $port
e47eec8f 245server.modules = ( "mod_setenv", "mod_cgi" )
a51d37c1
EW
246server.indexfiles = ( "gitweb.cgi" )
247server.pid-file = "$fqgitdir/pid"
be5347b3 248server.errorlog = "$fqgitdir/gitweb/$httpd_only/error.log"
e47eec8f
RJ
249
250# to enable, add "mod_access", "mod_accesslog" to server.modules
251# variable above and uncomment this
be5347b3 252#accesslog.filename = "$fqgitdir/gitweb/$httpd_only/access.log"
e47eec8f 253
c0cb4ed3 254setenv.add-environment = ( "PATH" => env.PATH, "GITWEB_CONFIG" => env.GITWEB_CONFIG )
e47eec8f 255
a51d37c1 256cgi.assign = ( ".cgi" => "" )
e47eec8f
RJ
257
258# mimetype mapping
259mimetype.assign = (
260 ".pdf" => "application/pdf",
261 ".sig" => "application/pgp-signature",
262 ".spl" => "application/futuresplash",
263 ".class" => "application/octet-stream",
264 ".ps" => "application/postscript",
265 ".torrent" => "application/x-bittorrent",
266 ".dvi" => "application/x-dvi",
267 ".gz" => "application/x-gzip",
268 ".pac" => "application/x-ns-proxy-autoconfig",
269 ".swf" => "application/x-shockwave-flash",
270 ".tar.gz" => "application/x-tgz",
271 ".tgz" => "application/x-tgz",
272 ".tar" => "application/x-tar",
273 ".zip" => "application/zip",
274 ".mp3" => "audio/mpeg",
275 ".m3u" => "audio/x-mpegurl",
276 ".wma" => "audio/x-ms-wma",
277 ".wax" => "audio/x-ms-wax",
278 ".ogg" => "application/ogg",
279 ".wav" => "audio/x-wav",
280 ".gif" => "image/gif",
281 ".jpg" => "image/jpeg",
282 ".jpeg" => "image/jpeg",
283 ".png" => "image/png",
284 ".xbm" => "image/x-xbitmap",
285 ".xpm" => "image/x-xpixmap",
286 ".xwd" => "image/x-xwindowdump",
287 ".css" => "text/css",
288 ".html" => "text/html",
289 ".htm" => "text/html",
290 ".js" => "text/javascript",
291 ".asc" => "text/plain",
292 ".c" => "text/plain",
293 ".cpp" => "text/plain",
294 ".log" => "text/plain",
295 ".conf" => "text/plain",
296 ".text" => "text/plain",
297 ".txt" => "text/plain",
298 ".dtd" => "text/xml",
299 ".xml" => "text/xml",
300 ".mpeg" => "video/mpeg",
301 ".mpg" => "video/mpeg",
302 ".mov" => "video/quicktime",
303 ".qt" => "video/quicktime",
304 ".avi" => "video/x-msvideo",
305 ".asf" => "video/x-ms-asf",
306 ".asx" => "video/x-ms-asf",
307 ".wmv" => "video/x-ms-wmv",
308 ".bz2" => "application/x-bzip",
309 ".tbz" => "application/x-bzip-compressed-tar",
310 ".tar.bz2" => "application/x-bzip-compressed-tar",
311 "" => "text/plain"
312 )
a51d37c1 313EOF
9126425d 314 test x"$local" = xtrue && echo 'server.bind = "127.0.0.1"' >> "$conf"
a51d37c1
EW
315}
316
317apache2_conf () {
4bdf8599
DM
318 if test -z "$module_path"
319 then
320 test -d "/usr/lib/httpd/modules" &&
321 module_path="/usr/lib/httpd/modules"
322 test -d "/usr/lib/apache2/modules" &&
323 module_path="/usr/lib/apache2/modules"
324 fi
a51d37c1 325 bind=
9126425d 326 test x"$local" = xtrue && bind='127.0.0.1:'
e24c76bf 327 echo 'text/css css' > "$fqgitdir/mime.types"
a51d37c1 328 cat > "$conf" <<EOF
44a167b0 329ServerName "git-instaweb"
c0cb4ed3
PKS
330ServerRoot "$root"
331DocumentRoot "$root"
be5347b3
PKS
332ErrorLog "$fqgitdir/gitweb/$httpd_only/error.log"
333CustomLog "$fqgitdir/gitweb/$httpd_only/access.log" combined
a51d37c1
EW
334PidFile "$fqgitdir/pid"
335Listen $bind$port
44a167b0
EW
336EOF
337
4bdf8599
DM
338 for mod in mime dir env log_config
339 do
340 if test -e $module_path/mod_${mod}.so
341 then
44a167b0
EW
342 echo "LoadModule ${mod}_module " \
343 "$module_path/mod_${mod}.so" >> "$conf"
344 fi
345 done
346 cat >> "$conf" <<EOF
e24c76bf 347TypesConfig "$fqgitdir/mime.types"
a51d37c1
EW
348DirectoryIndex gitweb.cgi
349EOF
350
351 # check to see if Dennis Stosberg's mod_perl compatibility patch
352 # (<20060621130708.Gcbc6e5c@leonov.stosberg.net>) has been applied
e1622bfc 353 if test -f "$module_path/mod_perl.so" &&
c0cb4ed3 354 sane_grep 'MOD_PERL' "$root/gitweb.cgi" >/dev/null
a51d37c1
EW
355 then
356 # favor mod_perl if available
357 cat >> "$conf" <<EOF
358LoadModule perl_module $module_path/mod_perl.so
359PerlPassEnv GIT_DIR
2989f516 360PerlPassEnv GIT_EXEC_PATH
c0cb4ed3 361PerlPassEnv GITWEB_CONFIG
a51d37c1
EW
362<Location /gitweb.cgi>
363 SetHandler perl-script
364 PerlResponseHandler ModPerl::Registry
365 PerlOptions +ParseHeaders
366 Options +ExecCGI
367</Location>
368EOF
369 else
370 # plain-old CGI
43d60d2e 371 resolve_full_httpd
9524cf29 372 list_mods=$(echo "$full_httpd" | sed 's/-f$/-l/')
e1622bfc 373 $list_mods | sane_grep 'mod_cgi\.c' >/dev/null 2>&1 || \
10d1432a
MR
374 if test -f "$module_path/mod_cgi.so"
375 then
376 echo "LoadModule cgi_module $module_path/mod_cgi.so" >> "$conf"
377 else
378 $list_mods | grep 'mod_cgid\.c' >/dev/null 2>&1 || \
379 if test -f "$module_path/mod_cgid.so"
380 then
381 echo "LoadModule cgid_module $module_path/mod_cgid.so" \
382 >> "$conf"
383 else
384 echo "You have no CGI support!"
385 exit 2
386 fi
387 echo "ScriptSock logs/gitweb.sock" >> "$conf"
388 fi
a51d37c1 389 cat >> "$conf" <<EOF
2989f516
DM
390PassEnv GIT_DIR
391PassEnv GIT_EXEC_PATH
392PassEnv GITWEB_CONFIG
a51d37c1
EW
393AddHandler cgi-script .cgi
394<Location /gitweb.cgi>
395 Options +ExecCGI
396</Location>
397EOF
398 fi
399}
400
0ded4758
WL
401mongoose_conf() {
402 cat > "$conf" <<EOF
403# Mongoose web server configuration file.
404# Lines starting with '#' and empty lines are ignored.
405# For detailed description of every option, visit
406# http://code.google.com/p/mongoose/wiki/MongooseManual
407
c0cb4ed3 408root $root
0ded4758
WL
409ports $port
410index_files gitweb.cgi
411#ssl_cert $fqgitdir/gitweb/ssl_cert.pem
be5347b3
PKS
412error_log $fqgitdir/gitweb/$httpd_only/error.log
413access_log $fqgitdir/gitweb/$httpd_only/access.log
0ded4758
WL
414
415#cgi setup
c0cb4ed3 416cgi_env PATH=$PATH,GIT_DIR=$GIT_DIR,GIT_EXEC_PATH=$GIT_EXEC_PATH,GITWEB_CONFIG=$GITWEB_CONFIG
0ded4758
WL
417cgi_interp $PERL
418cgi_ext cgi,pl
419
420# mimetype mapping
421mime_types .gz=application/x-gzip,.tar.gz=application/x-tgz,.tgz=application/x-tgz,.tar=application/x-tar,.zip=application/zip,.gif=image/gif,.jpg=image/jpeg,.jpeg=image/jpeg,.png=image/png,.css=text/css,.html=text/html,.htm=text/html,.js=text/javascript,.c=text/plain,.cpp=text/plain,.log=text/plain,.conf=text/plain,.text=text/plain,.txt=text/plain,.dtd=text/xml,.bz2=application/x-bzip,.tbz=application/x-bzip-compressed-tar,.tar.bz2=application/x-bzip-compressed-tar
422EOF
423}
424
78646987
JN
425plackup_conf () {
426 # generate a standalone 'plackup' server script in $fqgitdir/gitweb
427 # with embedded configuration; it does not use "$conf" file
428 cat > "$fqgitdir/gitweb/gitweb.psgi" <<EOF
429#!$PERL
430
431# gitweb - simple web interface to track changes in git repositories
432# PSGI wrapper and server starter (see http://plackperl.org)
433
434use strict;
435
436use IO::Handle;
437use Plack::MIME;
438use Plack::Builder;
439use Plack::App::WrapCGI;
440use CGI::Emulate::PSGI 0.07; # minimum version required to work with gitweb
441
442# mimetype mapping (from lighttpd_conf)
443Plack::MIME->add_type(
444 ".pdf" => "application/pdf",
445 ".sig" => "application/pgp-signature",
446 ".spl" => "application/futuresplash",
447 ".class" => "application/octet-stream",
448 ".ps" => "application/postscript",
449 ".torrent" => "application/x-bittorrent",
450 ".dvi" => "application/x-dvi",
451 ".gz" => "application/x-gzip",
452 ".pac" => "application/x-ns-proxy-autoconfig",
453 ".swf" => "application/x-shockwave-flash",
454 ".tar.gz" => "application/x-tgz",
455 ".tgz" => "application/x-tgz",
456 ".tar" => "application/x-tar",
457 ".zip" => "application/zip",
458 ".mp3" => "audio/mpeg",
459 ".m3u" => "audio/x-mpegurl",
460 ".wma" => "audio/x-ms-wma",
461 ".wax" => "audio/x-ms-wax",
462 ".ogg" => "application/ogg",
463 ".wav" => "audio/x-wav",
464 ".gif" => "image/gif",
465 ".jpg" => "image/jpeg",
466 ".jpeg" => "image/jpeg",
467 ".png" => "image/png",
468 ".xbm" => "image/x-xbitmap",
469 ".xpm" => "image/x-xpixmap",
470 ".xwd" => "image/x-xwindowdump",
471 ".css" => "text/css",
472 ".html" => "text/html",
473 ".htm" => "text/html",
474 ".js" => "text/javascript",
475 ".asc" => "text/plain",
476 ".c" => "text/plain",
477 ".cpp" => "text/plain",
478 ".log" => "text/plain",
479 ".conf" => "text/plain",
480 ".text" => "text/plain",
481 ".txt" => "text/plain",
482 ".dtd" => "text/xml",
483 ".xml" => "text/xml",
484 ".mpeg" => "video/mpeg",
485 ".mpg" => "video/mpeg",
486 ".mov" => "video/quicktime",
487 ".qt" => "video/quicktime",
488 ".avi" => "video/x-msvideo",
489 ".asf" => "video/x-ms-asf",
490 ".asx" => "video/x-ms-asf",
491 ".wmv" => "video/x-ms-wmv",
492 ".bz2" => "application/x-bzip",
493 ".tbz" => "application/x-bzip-compressed-tar",
494 ".tar.bz2" => "application/x-bzip-compressed-tar",
495 "" => "text/plain"
496);
497
498my \$app = builder {
499 # to be able to override \$SIG{__WARN__} to log build time warnings
500 use CGI::Carp; # it sets \$SIG{__WARN__} itself
501
502 my \$logdir = "$fqgitdir/gitweb/$httpd_only";
503 open my \$access_log_fh, '>>', "\$logdir/access.log"
504 or die "Couldn't open access log '\$logdir/access.log': \$!";
505 open my \$error_log_fh, '>>', "\$logdir/error.log"
506 or die "Couldn't open error log '\$logdir/error.log': \$!";
507
508 \$access_log_fh->autoflush(1);
509 \$error_log_fh->autoflush(1);
510
511 # redirect build time warnings to error.log
512 \$SIG{'__WARN__'} = sub {
513 my \$msg = shift;
514 # timestamp warning like in CGI::Carp::warn
515 my \$stamp = CGI::Carp::stamp();
516 \$msg =~ s/^/\$stamp/gm;
517 print \$error_log_fh \$msg;
518 };
519
520 # write errors to error.log, access to access.log
521 enable 'AccessLog',
522 format => "combined",
523 logger => sub { print \$access_log_fh @_; };
524 enable sub {
525 my \$app = shift;
526 sub {
527 my \$env = shift;
528 \$env->{'psgi.errors'} = \$error_log_fh;
529 \$app->(\$env);
530 }
531 };
532 # gitweb currently doesn't work with $SIG{CHLD} set to 'IGNORE',
533 # because it uses 'close $fd or die...' on piped filehandle $fh
534 # (which causes the parent process to wait for child to finish).
535 enable_if { \$SIG{'CHLD'} eq 'IGNORE' } sub {
536 my \$app = shift;
537 sub {
538 my \$env = shift;
539 local \$SIG{'CHLD'} = 'DEFAULT';
540 local \$SIG{'CLD'} = 'DEFAULT';
541 \$app->(\$env);
542 }
543 };
544 # serve static files, i.e. stylesheet, images, script
545 enable 'Static',
546 path => sub { m!\.(js|css|png)\$! && s!^/gitweb/!! },
547 root => "$root/",
548 encoding => 'utf-8'; # encoding for 'text/plain' files
549 # convert CGI application to PSGI app
550 Plack::App::WrapCGI->new(script => "$root/gitweb.cgi")->to_app;
551};
552
553# make it runnable as standalone app,
554# like it would be run via 'plackup' utility
555if (__FILE__ eq \$0) {
556 require Plack::Runner;
557
558 my \$runner = Plack::Runner->new();
559 \$runner->parse_options(qw(--env deployment --port $port),
560 "$local" ? qw(--host 127.0.0.1) : ());
561 \$runner->run(\$app);
562}
563__END__
564EOF
565
566 chmod a+x "$fqgitdir/gitweb/gitweb.psgi"
567 # configuration is embedded in server script file, gitweb.psgi
568 rm -f "$conf"
569}
570
c0cb4ed3
PKS
571gitweb_conf() {
572 cat > "$fqgitdir/gitweb/gitweb_config.perl" <<EOF
573#!/usr/bin/perl
574our \$projectroot = "$(dirname "$fqgitdir")";
575our \$git_temp = "$fqgitdir/gitweb/tmp";
576our \$projects_list = \$projectroot;
577EOF
4af819d4
JN
578}
579
c0cb4ed3 580gitweb_conf
a51d37c1 581
be5347b3
PKS
582resolve_full_httpd
583mkdir -p "$fqgitdir/gitweb/$httpd_only"
584
a51d37c1
EW
585case "$httpd" in
586*lighttpd*)
587 lighttpd_conf
588 ;;
4bdf8599 589*apache2*|*httpd*)
a51d37c1
EW
590 apache2_conf
591 ;;
425b78e8
MD
592webrick)
593 webrick_conf
594 ;;
0ded4758
WL
595*mongoose*)
596 mongoose_conf
597 ;;
78646987
JN
598*plackup*)
599 plackup_conf
600 ;;
a51d37c1
EW
601*)
602 echo "Unknown httpd specified: $httpd"
603 exit 1
604 ;;
605esac
606
607start_httpd
5209eda8 608url=http://127.0.0.1:$port
2e0c2902
CC
609
610if test -n "$browser"; then
d94775e1 611 httpd_is_ready && git web--browse -b "$browser" $url || echo $url
2e0c2902 612else
d94775e1 613 httpd_is_ready && git web--browse -c "instaweb.browser" $url || echo $url
2e0c2902 614fi