]> git.ipfire.org Git - thirdparty/git.git/commitdiff
git-instaweb: Check that correct config file exists for (re)start
authorJakub Narebski <jnareb@gmail.com>
Thu, 23 Jun 2011 21:01:03 +0000 (23:01 +0200)
committerEric Wong <normalperson@yhbt.net>
Mon, 27 Jun 2011 09:11:41 +0000 (09:11 +0000)
Currently start/restart does not generate any configuration files for
spawning a new instance.  This means that

  $ git instaweb --http=<server> --start

might pick up stale 'httpd.conf' file for a different web server
(e.g. for default lighttpd when requesting apache2).

This commit changes that, and makes git-instaweb generate web server
config file and/or gitweb config file if don't exists.

This required naming config files after the name of web server
(alternate solution would be to somehow mark for which web server was
config file generated).

Note that web servers that embed configuration in server script file,
namely webrick and plackup, and which delete "$conf" in their *_conf
function, would have their config (server script) always regenerated.

Note: this commit introduces a bit of code repetition (but only a few
lines).

Reported-by: Gurjeet Singh <singh.gurjeet@gmail.com>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Acked-by: Eric Wong <normalperson@yhbt.net>
Documentation/git-instaweb.txt
git-instaweb.sh

index 08f85ba046598070432e9d9cd45052ae20484402..ea95c90460b976ee187833c248366af579065f83 100644 (file)
@@ -51,8 +51,8 @@ OPTIONS
 
 start::
 --start::
-       Start the httpd instance and exit.  This does not generate
-       any of the configuration files for spawning a new instance.
+       Start the httpd instance and exit.  Regenerate configuration files
+       as necessary for spawning a new instance.
 
 stop::
 --stop::
@@ -62,8 +62,8 @@ stop::
 
 restart::
 --restart::
-       Restart the httpd instance and exit.  This does not generate
-       any of the configuration files for spawning a new instance.
+       Restart the httpd instance and exit.  Regenerate configuration files
+       as necessary for spawning a new instance.
 
 CONFIGURATION
 -------------
index 9a2f20f6adafb2e31d306155bd75c960de9fe512..01a1b05e6bdcd12f82f70282975780d3a19d910d 100755 (executable)
@@ -99,6 +99,12 @@ start_httpd () {
 
        # here $httpd should have a meaningful value
        resolve_full_httpd
+       mkdir -p "$fqgitdir/gitweb/$httpd_only"
+       conf="$fqgitdir/gitweb/$httpd_only.conf"
+
+       # generate correct config file if it doesn't exist
+       test -f "$conf" || configure_httpd
+       test -f "$fqgitdir/gitweb/gitweb_config.perl" || gitweb_conf
 
        # don't quote $full_httpd, there can be arguments to it (-f)
        case "$httpd" in
@@ -628,6 +634,7 @@ gitweb_conf
 
 resolve_full_httpd
 mkdir -p "$fqgitdir/gitweb/$httpd_only"
+conf="$fqgitdir/gitweb/$httpd_only.conf"
 
 configure_httpd