Bug 43748 - Demo broken
Summary: Demo broken
Alias: None
Product: Lenya
Classification: Unclassified
Component: Miscellaneous (show other bugs)
Version: unspecified
Hardware: Other SunOS
: P2 major
Target Milestone: 1.2.6
Assignee: Lenya Developers
URL: http://lenya.zones.apache.org:8888/
: 43959 (view as bug list)
Depends on:
Reported: 2007-10-31 05:43 UTC by Andreas Kuckartz
Modified: 2007-12-20 11:53 UTC (History)
1 user (show)


Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Kuckartz 2007-10-31 05:43:04 UTC
The start page http://lenya.apache.org contains a link to a "Demo" 
(http://lenya.zones.apache.org:8888/) but the link or the demo (or both) is 
Comment 1 Andreas Hartmann 2007-10-31 06:50:04 UTC
I restarted the server some hours ago (it was offline this morning because of
deployment changes, see bug 33147), it's up again.
Comment 2 Andreas Kuckartz 2007-10-31 07:12:37 UTC
It is down again...
Comment 3 Andreas Hartmann 2007-10-31 07:18:28 UTC
Sorry, I restarted only the trunk demo. I'll restart the branch demo now.
Comment 4 Andreas Hartmann 2007-11-01 05:04:37 UTC
The branch demo can't start:


./lenya.sh: using /export/home/lenya/build/lenya/webapp as the webapp directory
INFO: No such war file lenya.war or build directory!
Comment 5 Andreas Hartmann 2007-11-01 06:00:03 UTC
The lenya.sh script can't resolve LENYA_HOME. It works with the code from
2.0-dev. Here's the diff:

-# Set Lenya home to directory containing this script
-ENDSLASH=`expr match "$0" '.*/'`
-LENYA_HOME=`expr substr "$0" 1 $ENDSLASH`
-LENYA_HOME=`pwd -P`
+if [ "$LENYA_HOME" = "" ] ; then
+  # TODO: Make it startable from any directory
+  #LENYA_HOME=`dirname $0`

Should we commit this?
Comment 6 solprovider 2007-11-26 11:24:21 UTC
I committed the change in Comment #5.  Using an environmental variable does not
allow multiple versions of Lenya on one server.  The code sets LENYA_HOME to the
directory containing this instance of lenya.sh.  

The code uses "expr match", "expr substr", "cd" and "pwd".  Which of these
commands are not available in all versions of *nix?  Better (more generic) code
for discovering the current directory would be good.
Comment 7 solprovider 2007-11-27 17:19:33 UTC
According to http://issues.apache.org/bugzilla/show_bug.cgi?id=43959, MacOS
errors on the two "expr" lines (and so incorrectly sets LENYA_HOME so other
files are not found.)  Here is the same function without using "expr":


I will commit this tomorrow if nobody finds a problem.  Both versions were
tested with Bash 2.05.  What operating systems/bash versions do not like "expr"?
Comment 8 Andreas Hartmann 2007-11-27 17:21:51 UTC
The zones server runs solaris:

Sun Microsystems Inc.   SunOS 5.10      Generic January 2005
Comment 9 solprovider 2007-11-28 03:49:08 UTC
lenya.sh specifies:
sh calls the Bourne shell for POSIX compatibility.  In Linux, "sh" is Bash which
added the "expr" extensions.  Using those extensions broke compatibility. 
Tested using people.apache.org (FreeBSD 6.2): the current code errors and the
new code works.  I will commit the change later today.
Comment 10 solprovider 2007-11-29 04:13:11 UTC
*** Bug 43959 has been marked as a duplicate of this bug. ***
Comment 11 solprovider 2007-11-29 04:14:07 UTC
Broken in 589735 (2007-10-29).  Fixed in 599401 (2007-11-29) as specified in
Comment #7.
Comment 12 Andreas Hartmann 2007-12-03 01:04:50 UTC
It doesn't seem to work at the zones server:

./lenya.sh: bad substitution
Comment 13 Thorsten Scherler 2007-12-11 14:40:07 UTC

Can you explain this change?

If I open a shell and type 
echo ${0%/*}

I get

If I do this on the zone server I get:

For now I removed the lines 93 - 97 and replaced them with the ones from
r473841. Which seems to work fine.

This is pointed as well earlier out, what seems to be wrong with it?
Comment 14 Thorsten Scherler 2007-12-11 14:44:33 UTC
Hmm, I am starting understand.

If I do 
echo ${0%/*}

I get "." on my Ubuntu.

if I do this on zones I get
./test: bad substitution
Comment 16 Thorsten Scherler 2007-12-11 15:35:06 UTC
hmm, I found a interesting post:

echo ${0%/*}

Works nice.
Comment 17 Thorsten Scherler 2007-12-11 15:55:21 UTC

is as well working fine.
Comment 18 solprovider 2007-12-11 16:38:41 UTC
The goal of my revision to lenya.sh is to make LENYA_HOME independent
of an environment variable.  Before this change, running any of these
will start the same instance of Lenya because the environment variable
overrides the path of the command.  This is not intuitive.  Running
/lenya-1.2.5/lenya.sh should launch Lenya 1.2.5, not Lenya
1.2.2.  More critical, running multiple instances of Lenya is not
possible when the launch command always reverts to a single instance.
Editing lenya.sh in each instance to hardcode the directory
violates every rule of computing.

In ash, bash, csh, ksh, and every shell except the original 1977 sh,
will remove the last slash and anything after the last slash from the command.

echo $0
because echo is integral to bash so the "command" is bash.  Test using
the following script.

FILE: test.sh
echo "PWD= `pwd`"
echo "LH1=$LENYA_HOME"
echo "LH2=$LENYA_HOME"

Using people.apache.org:
/x1$ home/solprovider/test.sh
PWD= /x1

In English,
1. Get the path used to reach the current executable (LH1).
2. Change directory using the result of #1.  This is relative to the
current directory.  The current directory (PWD) is the directory from
which the command is called.
3. Get the absolute current path (LH2).  This removes dots and symbolic links.

This code works on every *nix except SunOS.  By default, SunOS uses the original
1977 shell, which did not have good string manipulation.  sh and awk
were the two required programs for Unix.    In 1977, string manipulation
required using awk.

I am ready to rewrite this to use awk to work on SunOS.  I am waiting
for access to zones so I can test the code.  I dislike guessing what
might work and submitting code hoping not to break anything.
Comment 19 solprovider 2007-12-11 17:03:55 UTC
The most desired solution is to use a 1977-compatible shell script.

Could we just specify that the default SunOS shell does not work?  SunOS
adminstrators know SunOS requires extra configuration for most programs.  For
Lenya, just run "chsh" as the Lenya user to change the shell.
sudo -u lenyauser chsh

Comment 20 J 2007-12-19 09:26:34 UTC
(In reply to comment #18)
> The goal of my revision to lenya.sh is to make LENYA_HOME independent
> of an environment variable.  Before this change, running any of these
> files:
>   /lenya-1.2.2/lenya.sh
>   /lenya-1.2.5/lenya.sh
>   /lenya-1.2.x/lenya.sh
> will start the same instance of Lenya because the environment variable
> overrides the path of the command. 

i don't know if it's posix or a GNUism, but
"LENYA_HOME=. ./lenya.sh" should do the trick...
i agree that using environment variables is weird - we should chuck them out and
add proper parameters for all this...
Comment 21 solprovider 2007-12-20 11:37:00 UTC

This code works for exactly one case -- lenya.sh must be called from
the Lenya directory.  Startup scripts must change to the Lenya
directory before calling the launch command, and may still have
unexpected results if LENYA_HOME is set as an environment variable.
To test, try to run Lenya from a different directory without setting
  cd /x1/home/solprovider
  /lenya-1.2.5/lenya.sh servlet
  INFO: No such war file lenya.war or build directory!
because the build directory and lenya.war file are not found in the
/x1/home/solprovider directory.

> Meaning when you do not set "$LENYA_HOME" it is the same as you intend
> with your commit.

Not setting LENYA_HOME still requires changing the directory before
calling lenya.sh.  I am unaware of another program that requires
changing the directory before calling the launch command.

I am not the only person aware of and working on this issue.  Trunk's
lenya.sh includes:
  if [ "$LENYA_HOME" = "" ] ; then
    # TODO: Make it startable from any directory
    #LENYA_HOME=`dirname $0`

Who tried using "dirname"?  That code cannot fix the issue because
LENYA_HOME is not set to the absolute path.  Can we use this code?

  cd `dirname $0`
  LENYA_HOME=`pwd -P`

Is the dirname program more generically available than the percent
sign syntax for string manipulation?

For the record, the rest of my original commit added a "stop" command
line option and automatically shut down the Lenya instance from this
directory before launching a new instance.  Lenya 2.0 should benefit
from that code.
Comment 22 solprovider 2007-12-20 11:45:08 UTC

cd `dirname $0`

This code works on zones.lenya.apache.org (Solaris 2.10), people.apache.org
(FreeBSD 6.2), and a Linux server.

Here are the results on zones:

FILE: /export/home/lenya/test
echo "PWD= `pwd`"
echo "CMD=$0"
LENYA_HOME=`dirname $0`
cd `dirname $0`
echo "LH3=$LENYA_HOME"

$ cd /export/home/lenya
$ ./test
PWD= /export/home/lenya
$ cd /opt/local
$ /export/home/lenya/test
PWD= /opt/local
Comment 23 solprovider 2007-12-20 11:53:59 UTC
Committed to 1.2 and 1.3 on 20071213.
Opened a new bugzilla for 2.0/Trunk: