{"thread":{"id":"13481","subject":"[PATCH v2] instaweb: make it compatible with Mac OS X 10.5's apache installation.","startedAt":"2008-05-11T19:36:09Z","lastAt":"2008-05-13T12:30:19Z","messageCount":6,"participants":["nathan spindel","Christian Couder","Junio C Hamano","Jakub Narebski"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"76659","messageId":"1210534569-48466-1-git-send-email-nathans@gmail.com","threadId":"13481","inReplyTo":null,"subject":"[PATCH v2] instaweb: make it compatible with Mac OS X 10.5's apache installation.","fromName":"nathan spindel","fromEmail":"nathans@gmail.com","sentAt":"2008-05-11T19:36:09Z","receivedAt":"2008-05-11T19:36:09Z","isPatch":true,"sender":{"key":"nathans@gmail.com","avatar":"https://gravatar.com/avatar/cccc9df7264bf4abc5d9d2fa5ce120607d2dd3741d429740b8edca4bfb4dcd1a?d=mp&s=160"},"body":"When in apache2 mode if there isn't an apache2 command on the\nsystem but there is a httpd command installed (like there is\non Mac OS X) use that command instead.\n\nWhen in apache2 mode and there isn't a module_path specified, look for\nmodule paths in /usr/lib/apache2/modules _and_ /usr/libexec/apache2,\nin that order.\n\nAdded a LockFile directive to the apache2 config because the default\nlocation of /private/var/run is only root-writeable on Mac OS X.\n\nSigned-off-by: nathan spindel <nathans@gmail.com>\n---\n git-instaweb.sh |   55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-\n 1 files changed, 54 insertions(+), 1 deletions(-)\n\ndiff --git a/git-instaweb.sh b/git-instaweb.sh\nindex 6f91c8f..00e147f 100755\n--- a/git-instaweb.sh\n+++ b/git-instaweb.sh\n@@ -172,7 +172,59 @@ EOF\n }\n \n apache2_conf () {\n-\ttest -z \"$module_path\" && module_path=/usr/lib/apache2/modules\n+\t# if there isn't an apache2 command on the system but there\n+\t# is a httpd command which looks like apache, use that instead\n+\t# for Mac OS X compatibility.\n+\thttpd_only=\"`echo $httpd | cut -f1 -d' '`\"\n+\tif ! type $httpd_only > /dev/null 2>&1\n+\tthen\n+\t\tfound_apache_command=1\n+\t\thttpd_parent_paths=\"/usr/local/sbin /usr/sbin\"\n+\t\tfor i in $httpd_parent_paths; do\n+\t\t\tif test -x \"$i/$httpd_only\"\n+\t\t\tthen\n+\t\t\t\tfound_apache_command=0\n+\t\t\t\tbreak\n+\t\t\tfi\n+\t\tdone\n+\n+\t\tif test $found_apache_command != 0\n+\t\tthen\n+\t\t\talt_apache=\"httpd\"\n+\t\t\tif type $alt_apache > /dev/null 2>&1\n+\t\t\tthen\n+\t\t\t\t$alt_apache -v | grep Apache > /dev/null 2>&1\n+\t\t\t\tif test $? == 0\n+\t\t\t\tthen\n+\t\t\t\t\thttpd=`echo \"$httpd\" | sed \"s/apache2/httpd/\"`\n+\t\t\t\telse\n+\t\t\t\t\tfor i in $httpd_parent_paths; do\n+\t\t\t\t\t\tif test -x \"$i/$alt_apache\"\n+\t\t\t\t\t\tthen\n+\t\t\t\t\t\t\t$i/$alt_apache -v | grep Apache > /dev/null 2>&1\n+\t\t\t\t\t\t\tif test $? == 0\n+\t\t\t\t\t\t\tthen\n+\t\t\t\t\t\t\t\thttpd=`echo \"$httpd\" | sed \"s/apache2/httpd/\"`\n+\t\t\t\t\t\t\t\tbreak\n+\t\t\t\t\t\t\tfi\n+\t\t\t\t\t\tfi\n+\t\t\t\t\tdone\n+\t\t\t\tfi\n+\t\t\tfi\n+\t\tfi\n+\tfi\n+\n+\tif test -z \"$module_path\"\n+\tthen\n+\t\tfor path in /usr/lib/apache2/modules /usr/libexec/apache2; do\n+\t\t\tif test -d \"$path\"\n+\t\t\tthen\n+\t\t\t\tmodule_path=\"$path\"\n+\t\t\t\tbreak\n+\t\t\tfi\n+\t\tdone\n+\tfi\n+\n \tmkdir -p \"$GIT_DIR/gitweb/logs\"\n \tbind=\n \ttest x\"$local\" = xtrue && bind='127.0.0.1:'\n@@ -182,6 +234,7 @@ ServerName \"git-instaweb\"\n ServerRoot \"$fqgitdir/gitweb\"\n DocumentRoot \"$fqgitdir/gitweb\"\n PidFile \"$fqgitdir/pid\"\n+LockFile \"$fqgitdir/gitweb/logs/accept.lock\"\n Listen $bind$port\n EOF\n \n-- \n1.5.5.1.179.g2fe4.dirty\n"},{"id":"76660","messageId":"B3990C52-0AF9-490C-86E1-B311144C6661@gmail.com","threadId":"13481","inReplyTo":"1210534569-48466-1-git-send-email-nathans@gmail.com","subject":"Re: [PATCH v2] instaweb: make it compatible with Mac OS X 10.5's apache installation.","fromName":"nathan spindel","fromEmail":"nathans@gmail.com","sentAt":"2008-05-11T19:41:46Z","receivedAt":"2008-05-11T19:41:46Z","isPatch":true,"sender":{"key":"nathans@gmail.com","avatar":"https://gravatar.com/avatar/cccc9df7264bf4abc5d9d2fa5ce120607d2dd3741d429740b8edca4bfb4dcd1a?d=mp&s=160"},"body":"On May 11, 2008, at 12:36 PM, nathan spindel wrote:\n\n> apache2_conf () {\n> -\ttest -z \"$module_path\" && module_path=/usr/lib/apache2/modules\n> +\t# if there isn't an apache2 command on the system but there\n> +\t# is a httpd command which looks like apache, use that instead\n> +\t# for Mac OS X compatibility.\n> +\thttpd_only=\"`echo $httpd | cut -f1 -d' '`\"\n> +\tif ! type $httpd_only > /dev/null 2>&1\n> +\tthen\n> +\t\tfound_apache_command=1\n> +\t\thttpd_parent_paths=\"/usr/local/sbin /usr/sbin\"\n> +\t\tfor i in $httpd_parent_paths; do\n> +\t\t\tif test -x \"$i/$httpd_only\"\n> +\t\t\tthen\n> +\t\t\t\tfound_apache_command=0\n> +\t\t\t\tbreak\n> +\t\t\tfi\n> +\t\tdone\n> +\n> +\t\tif test $found_apache_command != 0\n> +\t\tthen\n> +\t\t\talt_apache=\"httpd\"\n> +\t\t\tif type $alt_apache > /dev/null 2>&1\n> +\t\t\tthen\n> +\t\t\t\t$alt_apache -v | grep Apache > /dev/null 2>&1\n> +\t\t\t\tif test $? == 0\n> +\t\t\t\tthen\n> +\t\t\t\t\thttpd=`echo \"$httpd\" | sed \"s/apache2/httpd/\"`\n> +\t\t\t\telse\n> +\t\t\t\t\tfor i in $httpd_parent_paths; do\n> +\t\t\t\t\t\tif test -x \"$i/$alt_apache\"\n> +\t\t\t\t\t\tthen\n> +\t\t\t\t\t\t\t$i/$alt_apache -v | grep Apache > /dev/null 2>&1\n> +\t\t\t\t\t\t\tif test $? == 0\n> +\t\t\t\t\t\t\tthen\n> +\t\t\t\t\t\t\t\thttpd=`echo \"$httpd\" | sed \"s/apache2/httpd/\"`\n> +\t\t\t\t\t\t\t\tbreak\n> +\t\t\t\t\t\t\tfi\n> +\t\t\t\t\t\tfi\n> +\t\t\t\t\tdone\n> +\t\t\t\tfi\n> +\t\t\tfi\n> +\t\tfi\n> +\tfi\n\nI'd like to see a cleaner implementation of this logic, if anyone has  \nstrong shell-fu.\n"},{"id":"76729","messageId":"200805121952.55492.chriscool@tuxfamily.org","threadId":"13481","inReplyTo":"B3990C52-0AF9-490C-86E1-B311144C6661@gmail.com","subject":"Re: [PATCH v2] instaweb: make it compatible with Mac OS X 10.5's apache installation.","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2008-05-12T17:52:55Z","receivedAt":"2008-05-12T17:52:55Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Le dimanche 11 mai 2008, nathan spindel a écrit :\n> On May 11, 2008, at 12:36 PM, nathan spindel wrote:\n> > apache2_conf () {\n> > -\ttest -z \"$module_path\" && module_path=/usr/lib/apache2/modules\n> > +\t# if there isn't an apache2 command on the system but there\n> > +\t# is a httpd command which looks like apache, use that instead\n> > +\t# for Mac OS X compatibility.\n> > +\thttpd_only=\"`echo $httpd | cut -f1 -d' '`\"\n> > +\tif ! type $httpd_only > /dev/null 2>&1\n> > +\tthen\n> > +\t\tfound_apache_command=1\n> > +\t\thttpd_parent_paths=\"/usr/local/sbin /usr/sbin\"\n> > +\t\tfor i in $httpd_parent_paths; do\n> > +\t\t\tif test -x \"$i/$httpd_only\"\n> > +\t\t\tthen\n> > +\t\t\t\tfound_apache_command=0\n> > +\t\t\t\tbreak\n> > +\t\t\tfi\n> > +\t\tdone\n> > +\n> > +\t\tif test $found_apache_command != 0\n> > +\t\tthen\n> > +\t\t\talt_apache=\"httpd\"\n> > +\t\t\tif type $alt_apache > /dev/null 2>&1\n> > +\t\t\tthen\n> > +\t\t\t\t$alt_apache -v | grep Apache > /dev/null 2>&1\n> > +\t\t\t\tif test $? == 0\n> > +\t\t\t\tthen\n> > +\t\t\t\t\thttpd=`echo \"$httpd\" | sed \"s/apache2/httpd/\"`\n> > +\t\t\t\telse\n> > +\t\t\t\t\tfor i in $httpd_parent_paths; do\n> > +\t\t\t\t\t\tif test -x \"$i/$alt_apache\"\n> > +\t\t\t\t\t\tthen\n> > +\t\t\t\t\t\t\t$i/$alt_apache -v | grep Apache > /dev/null 2>&1\n> > +\t\t\t\t\t\t\tif test $? == 0\n> > +\t\t\t\t\t\t\tthen\n> > +\t\t\t\t\t\t\t\thttpd=`echo \"$httpd\" | sed \"s/apache2/httpd/\"`\n> > +\t\t\t\t\t\t\t\tbreak\n> > +\t\t\t\t\t\t\tfi\n> > +\t\t\t\t\t\tfi\n> > +\t\t\t\t\tdone\n> > +\t\t\t\tfi\n> > +\t\t\tfi\n> > +\t\tfi\n> > +\tfi\n>\n> I'd like to see a cleaner implementation of this logic, \n\nMaybe you can use a function like this not tested one:\n\ncheck_cmd() {\n\tcmd=\"$1\"\n\n\tif type \"$cmd\" > /dev/null 2>&1; then\n\t\tif \"$cmd\" -v | grep Apache > /dev/null 2>&1; then\n\t\t\thttpd=$(echo \"$cmd\" | sed \"s/apache2/httpd/\")\n\t\tfi\n\tfi\n}\n\nRegards,\nChristian.\n"},{"id":"76742","messageId":"7v7idzz7no.fsf@gitster.siamese.dyndns.org","threadId":"13481","inReplyTo":"200805121952.55492.chriscool@tuxfamily.org","subject":"Re: [PATCH v2] instaweb: make it compatible with Mac OS X 10.5's apache installation.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-05-12T18:42:03Z","receivedAt":"2008-05-12T18:42:03Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Christian Couder <chriscool@tuxfamily.org> writes:\n\n> Maybe you can use a function like this not tested one:\n>\n> check_cmd() {\n> \tcmd=\"$1\"\n>\n> \tif type \"$cmd\" > /dev/null 2>&1; then\n> \t\tif \"$cmd\" -v | grep Apache > /dev/null 2>&1; then\n> \t\t\thttpd=$(echo \"$cmd\" | sed \"s/apache2/httpd/\")\n> \t\tfi\n> \tfi\n> }\n\nOne worry I have with that approach is if any and all random\nimplementations of \"httpd\" that live somewhere in path do not do any harm\nwhen started with \"-v\" option.  Namely, they should exit without becoming\na daemon and/or start the service.\n\nI am not convinced that would be the case.\n"},{"id":"76825","messageId":"21CA1226-223D-4347-A119-1D5A2CEA003E@gmail.com","threadId":"13481","inReplyTo":"7v7idzz7no.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH v2] instaweb: make it compatible with Mac OS X 10.5's apache installation.","fromName":"nathan spindel","fromEmail":"nathans@gmail.com","sentAt":"2008-05-13T02:54:01Z","receivedAt":"2008-05-13T02:54:01Z","isPatch":true,"sender":{"key":"nathans@gmail.com","avatar":"https://gravatar.com/avatar/cccc9df7264bf4abc5d9d2fa5ce120607d2dd3741d429740b8edca4bfb4dcd1a?d=mp&s=160"},"body":"On May 12, 2008, at 11:42 AM, Junio C Hamano wrote:\n\n> Christian Couder <chriscool@tuxfamily.org> writes:\n>\n>> Maybe you can use a function like this not tested one:\n>>\n>> check_cmd() {\n>> \tcmd=\"$1\"\n>>\n>> \tif type \"$cmd\" > /dev/null 2>&1; then\n>> \t\tif \"$cmd\" -v | grep Apache > /dev/null 2>&1; then\n>> \t\t\thttpd=$(echo \"$cmd\" | sed \"s/apache2/httpd/\")\n>> \t\tfi\n>> \tfi\n>> }\n>\n> One worry I have with that approach is if any and all random\n> implementations of \"httpd\" that live somewhere in path do not do any  \n> harm\n> when started with \"-v\" option.  Namely, they should exit without  \n> becoming\n> a daemon and/or start the service.\n>\n> I am not convinced that would be the case.\n\nI agree with that worry. Solving that in the general case is pretty  \ndifficult, so I think we could instead look for other clues in the  \nsystem. Some ideas:\n\n- Use $HTTPD as defined in apachectl. (How portable is that?)\n\n- Inspect the text of 'man httpd' to determine if it's Apache or not.\n\n- Only fallback on the httpd command on Mac OS X 10.5? That's pretty  \nsafe.\n"},{"id":"76867","messageId":"m37idy5qvz.fsf@localhost.localdomain","threadId":"13481","inReplyTo":"21CA1226-223D-4347-A119-1D5A2CEA003E@gmail.com","subject":"Re: [PATCH v2] instaweb: make it compatible with Mac OS X 10.5's apache installation.","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2008-05-13T12:30:19Z","receivedAt":"2008-05-13T12:30:19Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"nathan spindel <nathans@gmail.com> writes:\n\n> On May 12, 2008, at 11:42 AM, Junio C Hamano wrote:\n> \n>> Christian Couder <chriscool@tuxfamily.org> writes:\n>>\n>>> Maybe you can use a function like this not tested one:\n>>>\n>>> check_cmd() {\n>>> \tcmd=\"$1\"\n>>>\n>>> \tif type \"$cmd\"> /dev/null 2>&1; then\n>>> \t\tif \"$cmd\" -v | grep Apache> /dev/null 2>&1; then\n>>> \t\t\thttpd=$(echo \"$cmd\" | sed \"s/apache2/httpd/\")\n>>> \t\tfi\n>>> \tfi\n>>> }\n>>\n>> One worry I have with that approach is if any and all random\n>> implementations of \"httpd\" that live somewhere in path do not do\n>> any harm when started with \"-v\" option.  Namely, they should exit\n>> without becoming a daemon and/or start the service.\n>>\n>> I am not convinced that would be the case.\n\nBy the way, it is a bit strange that Apache doesn't understand long\nequivalent of -v, namely --version.\n\n> I agree with that worry. Solving that in the general case is pretty\n> difficult, so I think we could instead look for other clues in the\n> system. Some ideas:\n> \n> - Use $HTTPD as defined in apachectl. (How portable is that?)\n\nYou mean what apachectl returns in Usage: (first line)?\n\n  1014:jnareb@roke:~> /usr/sbin/apachectl          \n  Usage: /usr/sbin/httpd [-D name] [-d directory] [-f file]\n\n> - Inspect the text of 'man httpd' to determine if it's Apache or not.\n\nManpages might be not installed.  I think 'httpd -v' is less error\nprone...\n\n> - Only fallback on the httpd command on Mac OS X 10.5? That's pretty\n> safe.\n\nNot only MacOS X has Apache installed as httpd binary.  Some Linux\ndistributions do that too.\n\n\nP.S. I wonder if it would be possible, as absolutely last resort\nfallback, to make git-instaweb to create/use very simple web server in\nPerl, using HTTP::Daemon module (if it is installed), which comes from\nlibwww-perl.\n\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"}]}