threads / patch / 4991

patch, 5 partsgit-instaweb: Fall back to Apache when LigHTTP was not found

Subject: [PATCH 4/5] git-instaweb: Fall back to Apache when LigHTTP was not found

## tl;dr

4 messages between Jul 26, 2006 and Jul 26, 2006. Diffs are folded; open one to read it.

replies: 3people: 2as markdown or json

Johannes Schindelin· Jul 26, 2006, 14:34 UTC · lore
Apache is more likely to be installed...
Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
---
 git-instaweb.sh |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)
Show changes to git-instaweb.sh +9 −3
diff --git a/git-instaweb.sh b/git-instaweb.sh
index 1d3ea73..242b55e 100755
--- a/git-instaweb.sh
+++ b/git-instaweb.sh
@@ -25,9 +25,6 @@ conf=$GIT_DIR/gitweb/httpd.conf
 
 # Defaults:
 
-# if installed, it doesn't need further configuration (module_path)
-test -z "$httpd" && httpd='lighttpd -f'
-
 # probably the most popular browser among gitweb users
 test -z "$browser" && browser='firefox'
 
@@ -135,6 +132,15 @@ do
 	shift
 done
 
+# if installed, it doesn't need further configuration (module_path)
+if [ -z "$httpd" ]; then
+	httpd='lighttpd -f'
+	which "$httpd" >/dev/null 2>&1 || httpd='apache2 -f'
+	which "$httpd" >/dev/null 2>&1 || httpd='apache -f'
+	which "$httpd" >/dev/null 2>&1 || httpd='httpd -f'
+	which "$httpd" >/dev/null || exit 1
+fi
+
 mkdir -p "$GIT_DIR/gitweb/tmp"
 GIT_EXEC_PATH="`git --exec-path`"
 GIT_DIR="$fqgitdir"
-- 
1.4.2.rc2.g6a4e
Junio C Hamano· Jul 26, 2006, 19:22 UTC · re: Johannes Schindelin · lore

Re: [PATCH 4/5] git-instaweb: Fall back to Apache when LigHTTP was not found

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 34 quoted lines
> Apache is more likely to be installed...
>
> Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
> ---
>  git-instaweb.sh |   12 +++++++++---
>  1 files changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/git-instaweb.sh b/git-instaweb.sh
> index 1d3ea73..242b55e 100755
> --- a/git-instaweb.sh
> +++ b/git-instaweb.sh
> @@ -25,9 +25,6 @@ conf=$GIT_DIR/gitweb/httpd.conf
>  
>  # Defaults:
>  
> -# if installed, it doesn't need further configuration (module_path)
> -test -z "$httpd" && httpd='lighttpd -f'
> -
>  # probably the most popular browser among gitweb users
>  test -z "$browser" && browser='firefox'
>  
> @@ -135,6 +132,15 @@ do
>  	shift
>  done
>  
> +# if installed, it doesn't need further configuration (module_path)
> +if [ -z "$httpd" ]; then
> +	httpd='lighttpd -f'
> +	which "$httpd" >/dev/null 2>&1 || httpd='apache2 -f'
> +	which "$httpd" >/dev/null 2>&1 || httpd='apache -f'
> +	which "$httpd" >/dev/null 2>&1 || httpd='httpd -f'
> +	which "$httpd" >/dev/null || exit 1
> +fi
> +
Please don't use "which" in scripts.  Consult this thread:
http://thread.gmane.org/gmane.comp.version-control.git/23382/focus=23394
Johannes Schindelin· Jul 26, 2006, 19:57 UTC · re: Junio C Hamano · lore

Re: [PATCH 4/5] git-instaweb: Fall back to Apache when LigHTTP was not found

Hi,
On Wed, 26 Jul 2006, Junio C Hamano wrote:
> Please don't use "which" in scripts.  Consult this thread:
> 
> http://thread.gmane.org/gmane.comp.version-control.git/23382/focus=23394
I remembered vaguely, so I searched in git-instaweb:

$ git grep -n which next:git-instaweb.sh next:git-instaweb.sh:40: [white space...] which $httpd_only >/dev/null

Well, the fallback mechanism might not be that useful anyway: if you have apache, you have to specify the modules path. I'll do a patch instead which exits cleanly if either $httpd or $browser could not be executed, okay?

Ciao, Dscho

Johannes Schindelin· Jul 26, 2006, 21:11 UTC · re: Johannes Schindelin · lore

[PATCH] instaweb: Be more clear if httpd or the browser fail

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
---
On Wed, 26 Jul 2006, Johannes Schindelin wrote:
> Well, the fallback mechanism might not be that useful anyway: if you have 
> apache, you have to specify the modules path. I'll do a patch instead 
> which exits cleanly if either $httpd or $browser could not be executed, 
> okay?
Here you are
 git-instaweb.sh |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
Show changes to git-instaweb.sh +7 −2
diff --git a/git-instaweb.sh b/git-instaweb.sh
index 1d3ea73..585ad7c 100755
--- a/git-instaweb.sh
+++ b/git-instaweb.sh
@@ -54,6 +54,10 @@ start_httpd () {
 			fi
 		done
 	fi
+	if test $? != 0; then
+		echo "Could not execute http daemon $httpd."
+		exit 1
+	fi
 }
 
 stop_httpd () {
@@ -189,7 +193,7 @@ EOF
 	else
 		# plain-old CGI
 		list_mods=`echo "$httpd" | sed "s/-f$/-l/"`
-		$list_mods | grep 'mod_cgi\.c' >/dev/null || \
+		$list_mods | grep 'mod_cgi\.c' >/dev/null 2>&1 || \
 		echo "LoadModule cgi_module $module_path/mod_cgi.so" >> "$conf"
 		cat >> "$conf" <<EOF
 AddHandler cgi-script .cgi
@@ -239,4 +243,5 @@ esac
 
 start_httpd
 test -z "$browser" && browser=echo
-$browser http://127.0.0.1:$port
+url=http://127.0.0.1:$port
+$browser $url || echo $url
-- 
1.4.2.rc2.g84db

← back to recent threads