@@ -57,6 +57,13 @@ resolve_full_httpd () {
57
57
httpd_only=" ${httpd%% * } " # cut on first space
58
58
return
59
59
;;
60
+ * webrick* )
61
+ # server is started by running via generated webrick.rb in
62
+ # $fqgitdir/gitweb
63
+ full_httpd=" $fqgitdir /gitweb/webrick.rb"
64
+ httpd_only=" ${httpd%% * } " # cut on first space
65
+ return
66
+ ;;
60
67
esac
61
68
62
69
httpd_only=" $( echo $httpd | cut -f1 -d' ' ) "
@@ -188,40 +195,53 @@ GITWEB_CONFIG="$fqgitdir/gitweb/gitweb_config.perl"
188
195
export GIT_EXEC_PATH GIT_DIR GITWEB_CONFIG
189
196
190
197
webrick_conf () {
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
207
+ GIT_EXEC_PATH=$GIT_EXEC_PATH GIT_DIR=$GIT_DIR GITWEB_CONFIG=$GITWEB_CONFIG
208
+ export GIT_EXEC_PATH GIT_DIR GITWEB_CONFIG
209
+ exec $root /gitweb.cgi
210
+ EOF
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.
191
215
# generate a standalone server script in $fqgitdir/gitweb.
192
216
cat > " $fqgitdir /gitweb/$httpd .rb" << EOF
217
+ #!/usr/bin/env ruby
193
218
require 'webrick'
194
- require 'yaml'
195
- options = YAML::load_file(ARGV[0])
196
- options[:StartCallback] = proc do
197
- File.open(options[:PidFile],"w") do |f|
198
- f.puts Process.pid
199
- end
200
- end
201
- options[:ServerType] = WEBrick::Daemon
219
+ require 'logger'
220
+ options = {
221
+ :Port => $port ,
222
+ :DocumentRoot => "$root ",
223
+ :Logger => Logger.new('$fqgitdir /gitweb/error.log'),
224
+ :AccessLog => [
225
+ [ Logger.new('$fqgitdir /gitweb/access.log'),
226
+ WEBrick::AccessLog::COMBINED_LOG_FORMAT ]
227
+ ],
228
+ :DirectoryIndex => ["gitweb.cgi"],
229
+ :CGIInterpreter => "$wrapper ",
230
+ :StartCallback => lambda do
231
+ File.open("$fqgitdir /pid", "w") { |f| f.puts Process.pid }
232
+ end,
233
+ :ServerType => WEBrick::Daemon,
234
+ }
235
+ options[:BindAddress] = '127.0.0.1' if "$local " == "true"
202
236
server = WEBrick::HTTPServer.new(options)
203
237
['INT', 'TERM'].each do |signal|
204
238
trap(signal) {server.shutdown}
205
239
end
206
240
server.start
207
241
EOF
208
- # generate a shell script to invoke the above ruby script,
209
- # which assumes _ruby_ is in the user's $PATH. that's _one_
210
- # portable way to run ruby, which could be installed anywhere,
211
- # really.
212
- cat > " $fqgitdir /gitweb/$httpd " << EOF
213
- #!/bin/sh
214
- exec ruby "$fqgitdir /gitweb/$httpd .rb" \$ *
215
- EOF
216
- chmod +x " $fqgitdir /gitweb/$httpd "
217
-
218
- cat > " $conf " << EOF
219
- :Port: $port
220
- :DocumentRoot: "$root "
221
- :DirectoryIndex: ["gitweb.cgi"]
222
- :PidFile: "$fqgitdir /pid"
223
- EOF
224
- test " $local " = true && echo ' :BindAddress: "127.0.0.1"' >> " $conf "
242
+ chmod +x " $fqgitdir /gitweb/$httpd .rb"
243
+ # configuration is embedded in server script file, webrick.rb
244
+ rm -f " $conf "
225
245
}
226
246
227
247
lighttpd_conf () {
0 commit comments