3 # Copyright (c) 2006 Eric Wong
5 USAGE
='[--start] [--stop] [--restart]
6 [--local] [--httpd=<httpd>] [--port=<port>] [--browser=<browser>]
7 [--module-path=<path> (for Apache2 only)]'
13 fqgitdir
="$GIT_DIR" ;;
15 fqgitdir
="$PWD/$GIT_DIR" ;;
18 local="`git repo-config --bool --get instaweb.local`"
19 httpd
="`git repo-config --get instaweb.httpd`"
20 browser
="`git repo-config --get instaweb.browser`"
21 port
=`git repo-config --get instaweb.port`
22 module_path
="`git repo-config --get instaweb.modulepath`"
24 conf
=$GIT_DIR/gitweb
/httpd.conf
28 # if installed, it doens't need further configuration (module_path)
29 test -z "$httpd" && httpd
='lighttpd -f'
31 # probably the most popular browser among gitweb users
32 test -z "$browser" && browser
='firefox'
34 # any untaken local port will do...
35 test -z "$port" && port
=1234
38 httpd_only
="`echo $httpd | cut -f1 -d' '`"
39 if test "`expr index $httpd_only /`" -eq '1' || \
40 which $httpd_only >/dev
/null
42 $httpd $fqgitdir/gitweb
/httpd.conf
44 # many httpds are installed in /usr/sbin or /usr/local/sbin
45 # these days and those are not in most users $PATHs
46 for i
in /usr
/local
/sbin
/usr
/sbin
48 if test -x "$i/$httpd_only"
50 # don't quote $httpd, there can be
51 # arguments to it (-f)
52 $i/$httpd "$fqgitdir/gitweb/httpd.conf"
60 test -f "$fqgitdir/pid" && kill `cat "$fqgitdir/pid"`
63 while case "$#" in 0) break ;; esac
85 httpd
=`expr "$1" : '-[^=]*=\(.*\)'` ;;
93 -b|
--browser|
--browser=*)
96 browser
=`expr "$1" : '-[^=]*=\(.*\)'` ;;
107 port
=`expr "$1" : '-[^=]*=\(.*\)'` ;;
115 -m|
--module-path=*|
--module-path)
118 module_path
=`expr "$1" : '-[^=]*=\(.*\)'` ;;
133 mkdir
-p "$GIT_DIR/gitweb/tmp"
134 GIT_EXEC_PATH
="`git --exec-path`"
136 export GIT_EXEC_PATH GIT_DIR
141 server.document-root = "$fqgitdir/gitweb"
143 server.modules = ( "mod_cgi" )
144 server.indexfiles = ( "gitweb.cgi" )
145 server.pid-file = "$fqgitdir/pid"
146 cgi.assign = ( ".cgi" => "" )
147 mimetype.assign = ( ".css" => "text/css" )
149 test "$local" = true
&& echo 'server.bind = "127.0.0.1"' >> "$conf"
153 test -z "$module_path" && module_path
=/usr
/lib
/apache
2/modules
154 mkdir
-p "$GIT_DIR/gitweb/logs"
156 test "$local" = true
&& bind='127.0.0.1:'
157 echo 'text/css css' > $fqgitdir/mime.types
159 ServerRoot "$fqgitdir/gitweb"
160 DocumentRoot "$fqgitdir/gitweb"
161 PidFile "$fqgitdir/pid"
163 TypesConfig $fqgitdir/mime.types
164 DirectoryIndex gitweb.cgi
167 # check to see if Dennis Stosberg's mod_perl compatibility patch
168 # (<20060621130708.Gcbc6e5c@leonov.stosberg.net>) has been applied
169 if test -f "$module_path/mod_perl.so" && grep '^our $gitbin' \
170 "$GIT_DIR/gitweb/gitweb.cgi" >/dev
/null
172 # favor mod_perl if available
174 LoadModule perl_module $module_path/mod_perl.so
176 PerlPassEnv GIT_EXEC_DIR
177 <Location /gitweb.cgi>
178 SetHandler perl-script
179 PerlResponseHandler ModPerl::Registry
180 PerlOptions +ParseHeaders
187 LoadModule cgi_module $module_path/mod_cgi.so
188 AddHandler cgi-script .cgi
189 <Location /gitweb.cgi>
197 s#^\(my\|our\) $projectroot =.*#\1 $projectroot = "'`dirname $fqgitdir`'";#
198 s#\(my\|our\) $gitbin =.*#\1 $gitbin = "'$GIT_EXEC_PATH'";#
199 s#\(my\|our\) $projects_list =.*#\1 $projects_list = $projectroot;#
200 s#\(my\|our\) $git_temp =.*#\1 $git_temp = "'$fqgitdir/gitweb
/tmp
'";#'
203 cat > "$1.tmp" <<\EOFGITWEB
206 sed "$script" "$1.tmp" > "$1"
212 cat > "$1" <<\EOFGITWEB
217 gitweb_cgi
$GIT_DIR/gitweb
/gitweb.cgi
218 gitweb_css
$GIT_DIR/gitweb
/gitweb.css
228 echo "Unknown httpd specified: $httpd"
234 test -z "$browser" && browser
=echo
235 $browser http
://127.0.0.1:$port