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 broken.
I restarted the server some hours ago (it was offline this morning because of deployment changes, see bug 33147), it's up again.
It is down again...
Sorry, I restarted only the trunk demo. I'll restart the branch demo now.
The branch demo can't start: /export/home/lenya/htdocs/build/site/log/lenya.branch.update.log ./lenya.sh: using /export/home/lenya/build/lenya/webapp as the webapp directory INFO: No such war file lenya.war or build directory!
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` -cd $LENYA_HOME -LENYA_HOME=`pwd -P` +if [ "$LENYA_HOME" = "" ] ; then + LENYA_HOME='.' + # TODO: Make it startable from any directory + #LENYA_HOME=`dirname $0` + #echo "LENYA_HOME: $LENYA_HOME" +fi Should we commit this?
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.
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": LENYA_HOME=${0%/*} cd $LENYA_HOME LENYA_HOME=`pwd -P` 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"?
The zones server runs solaris: Sun Microsystems Inc. SunOS 5.10 Generic January 2005
lenya.sh specifies: #!/bin/sh 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.
*** Bug 43959 has been marked as a duplicate of this bug. ***
Broken in 589735 (2007-10-29). Fixed in 599401 (2007-11-29) as specified in Comment #7.
It doesn't seem to work at the zones server: ./lenya.sh: bad substitution
+LENYA_HOME=${0%/*} Can you explain this change? If I open a shell and type echo ${0%/*} I get bash If I do this on the zone server I get: -bash http://svn.apache.org/viewvc/lenya/branches/BRANCH_1_2_X/lenya.sh?r1=473841&r2=589735&pathrev=599401&diff_format=h 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?
Hmm, I am starting understand. If I do #!/bin/sh echo ${0%/*} I get "." on my Ubuntu. if I do this on zones I get ./test: bad substitution
http://moka.ccr.jussieu.fr/doc_link/en_US/a_doc_lib/aixuser/usrosdev/parameter_subst.htm
hmm, I found a interesting post: http://kerneltrap.org/mailarchive/git/2007/8/3/253869 Using #!/usr/xpg4/bin/sh echo ${0%/*} Works nice.
Using /bin/ksh is as well working fine.
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. 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, ${0%/*} will remove the last slash and anything after the last slash from the command. echo $0 returns -bash because echo is integral to bash so the "command" is bash. Test using the following script. FILE: test.sh #!/bin/sh echo "PWD= `pwd`" LENYA_HOME=${0%/*} echo "LH1=$LENYA_HOME" cd $LENYA_HOME LENYA_HOME=`pwd -P` echo "LH2=$LENYA_HOME" Using people.apache.org: /x1$ home/solprovider/test.sh PWD= /x1 LH1=home/solprovider LH2=/x1/home/solprovider 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.
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
(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...
LENYA_HOME='.' 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 LENYA_HOME: cd /x1/home/solprovider /lenya-1.2.5/lenya.sh servlet Results: 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 LENYA_HOME='.' # TODO: Make it startable from any directory #LENYA_HOME=`dirname $0` #echo "LENYA_HOME: $LENYA_HOME" fi 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.
RESOLVED WITH: cd `dirname $0` LENYA_HOME=`pwd -P` 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 #!/bin/sh echo "PWD= `pwd`" echo "CMD=$0" LENYA_HOME=`dirname $0` echo "DIR=$LENYA_HOME" cd `dirname $0` LENYA_HOME=`pwd -P` echo "LH3=$LENYA_HOME" $ cd /export/home/lenya $ ./test PWD= /export/home/lenya CMD=./test DIR=. LH3=/export/home/lenya $ cd /opt/local $ /export/home/lenya/test PWD= /opt/local CMD=/export/home/lenya/test DIR=/export/home/lenya LH3=/export/home/lenya
Committed to 1.2 and 1.3 on 20071213. Opened a new bugzilla for 2.0/Trunk: http://issues.apache.org/bugzilla/show_bug.cgi?id=44115