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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Le dimanche 11 mai 2008, nathan spindel a écrit :
> On May 11, 2008, at 12:36 PM, nathan spindel wrote:
> > apache2_conf () {
> > -	test -z "$module_path" && module_path=/usr/lib/apache2/modules
> > +	# if there isn't an apache2 command on the system but there
> > +	# is a httpd command which looks like apache, use that instead
> > +	# for Mac OS X compatibility.
> > +	httpd_only="`echo $httpd | cut -f1 -d' '`"
> > +	if ! type $httpd_only > /dev/null 2>&1
> > +	then
> > +		found_apache_command=1
> > +		httpd_parent_paths="/usr/local/sbin /usr/sbin"
> > +		for i in $httpd_parent_paths; do
> > +			if test -x "$i/$httpd_only"
> > +			then
> > +				found_apache_command=0
> > +				break
> > +			fi
> > +		done
> > +
> > +		if test $found_apache_command != 0
> > +		then
> > +			alt_apache="httpd"
> > +			if type $alt_apache > /dev/null 2>&1
> > +			then
> > +				$alt_apache -v | grep Apache > /dev/null 2>&1
> > +				if test $? == 0
> > +				then
> > +					httpd=`echo "$httpd" | sed "s/apache2/httpd/"`
> > +				else
> > +					for i in $httpd_parent_paths; do
> > +						if test -x "$i/$alt_apache"
> > +						then
> > +							$i/$alt_apache -v | grep Apache > /dev/null 2>&1
> > +							if test $? == 0
> > +							then
> > +								httpd=`echo "$httpd" | sed "s/apache2/httpd/"`
> > +								break
> > +							fi
> > +						fi
> > +					done
> > +				fi
> > +			fi
> > +		fi
> > +	fi
>
> I'd like to see a cleaner implementation of this logic, 

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
}

Regards,
Christian.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux