git-instaweb: Check that correct config file exists for (re)start

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>

Jakub Narebski committed Jun 23, 2011 at 23:01 UTC 5ad6d387f19d9dd28b323f5cfea8663cb7b74617
2 files changed +11 -4
Documentation/git-instaweb.txt
+4 -4
@@ -51,8 +51,8 @@ OPTIONS
51
52 start::
53 --start::
54 - Start the httpd instance and exit. This does not generate
55 - any of the configuration files for spawning a new instance.
54 + Start the httpd instance and exit. Regenerate configuration files
55 + as necessary for spawning a new instance.
56
57 stop::
58 --stop::
@@ -62,8 +62,8 @@ stop::
62
63 restart::
64 --restart::
65 - Restart the httpd instance and exit. This does not generate
66 - any of the configuration files for spawning a new instance.
65 + Restart the httpd instance and exit. Regenerate configuration files
66 + as necessary for spawning a new instance.
67
68 CONFIGURATION
69 -------------
git-instaweb.sh
+7
@@ -99,6 +99,12 @@ start_httpd () {
99
100 # here $httpd should have a meaningful value
101 resolve_full_httpd
102 + mkdir -p "$fqgitdir/gitweb/$httpd_only"
103 + conf="$fqgitdir/gitweb/$httpd_only.conf"
104 +
105 + # generate correct config file if it doesn't exist
106 + test -f "$conf" || configure_httpd
107 + test -f "$fqgitdir/gitweb/gitweb_config.perl" || gitweb_conf
108
109 # don't quote $full_httpd, there can be arguments to it (-f)
110 case "$httpd" in
@@ -628,6 +634,7 @@ gitweb_conf
634
635 resolve_full_httpd
636 mkdir -p "$fqgitdir/gitweb/$httpd_only"
637 +conf="$fqgitdir/gitweb/$httpd_only.conf"
638
639 configure_httpd
640