Thread (6 messages) flat view 6 messages, 4 authors, 2016-06-15

Re: [PATCH v2] instaweb: make it compatible with Mac OS X 10.5's apache installation.

From: Jakub Narebski <hidden>
Date: 2016-06-15 22:44:36

nathan spindel [off-list ref] writes:
On May 12, 2008, at 11:42 AM, Junio C Hamano wrote:
quoted
Christian Couder [off-list ref] writes:
quoted
Maybe you can use a function like this not tested one:

check_cmd() {
	cmd="$1"

	if type "$cmd"> /dev/null 2>&1; then
		if "$cmd" -v | grep Apache> /dev/null 2>&1; then
			httpd=$(echo "$cmd" | sed "s/apache2/httpd/")
		fi
	fi
}
One worry I have with that approach is if any and all random
implementations of "httpd" that live somewhere in path do not do
any harm when started with "-v" option.  Namely, they should exit
without becoming a daemon and/or start the service.

I am not convinced that would be the case.
By the way, it is a bit strange that Apache doesn't understand long
equivalent of -v, namely --version.
I agree with that worry. Solving that in the general case is pretty
difficult, so I think we could instead look for other clues in the
system. Some ideas:

- Use $HTTPD as defined in apachectl. (How portable is that?)
You mean what apachectl returns in Usage: (first line)?

  1014:jnareb@roke:~> /usr/sbin/apachectl          
  Usage: /usr/sbin/httpd [-D name] [-d directory] [-f file]
- Inspect the text of 'man httpd' to determine if it's Apache or not.
Manpages might be not installed.  I think 'httpd -v' is less error
prone...
- Only fallback on the httpd command on Mac OS X 10.5? That's pretty
safe.
Not only MacOS X has Apache installed as httpd binary.  Some Linux
distributions do that too.


P.S. I wonder if it would be possible, as absolutely last resort
fallback, to make git-instaweb to create/use very simple web server in
Perl, using HTTP::Daemon module (if it is installed), which comes from
libwww-perl.

-- 
Jakub Narebski
Poland
ShadeHawk on #git
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help