Author: markt
Date: Tue Jul  3 15:39:14 2018
New Revision: 1834991

URL: http://svn.apache.org/viewvc?rev=1834991&view=rev
Log:
Fix problem finding conf directory when $0 is './makebase.sh' by copying 
standard code from other .sh scripts.
Replace 'HOME_DIR' with 'CATALINA_HOME'. Non-standard name is confusing. Value 
is not exported so this should be safe.

Modified:
    tomcat/trunk/bin/makebase.sh

Modified: tomcat/trunk/bin/makebase.sh
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/bin/makebase.sh?rev=1834991&r1=1834990&r2=1834991&view=diff
==============================================================================
--- tomcat/trunk/bin/makebase.sh (original)
+++ tomcat/trunk/bin/makebase.sh Tue Jul  3 15:39:14 2018
@@ -25,6 +25,25 @@
 #
 # Usage: makebase <path-to-target-directory>
 
+# resolve links - $0 may be a softlink
+PRG="$0"
+
+while [ -h "$PRG" ]; do
+  ls=`ls -ld "$PRG"`
+  link=`expr "$ls" : '.*-> \(.*\)$'`
+  if expr "$link" : '/.*' > /dev/null; then
+    PRG="$link"
+  else
+    PRG=`dirname "$PRG"`/"$link"
+  fi
+done
+
+# Get standard environment variables
+PRGDIR=`dirname "$PRG"`
+
+# Only set CATALINA_HOME if not already set
+[ -z "$CATALINA_HOME" ] && CATALINA_HOME=`cd "$PRGDIR/.." >/dev/null; pwd`
+
 # first arg is the target directory
 BASE_TGT=$1
 
@@ -34,8 +53,6 @@ if [ -z ${BASE_TGT} ]; then
     exit 1
 fi
 
-HOME_DIR="$(dirname $(dirname $0))"
-
 if [ -d ${BASE_TGT} ]; then
   # target directory exists
   echo "Target directory exists"
@@ -56,11 +73,11 @@ do
 done
 
 # copy conf directory recursively and preserve permissions
-cp -a "${HOME_DIR}/conf" "${BASE_TGT}/"
+cp -a "${CATALINA_HOME}/conf" "${BASE_TGT}/"
 
 # copy setenv.sh if exists
-[ -f "${HOME_DIR}/bin/setenv.sh" ] && \
-    cp "${HOME_DIR}/bin/setenv.sh" "${BASE_TGT}/bin/"
+[ -f "${CATALINA_HOME}/bin/setenv.sh" ] && \
+    cp "${CATALINA_HOME}/bin/setenv.sh" "${BASE_TGT}/bin/"
 
 echo "Created CATALINA_BASE directory at $BASE_TGT"
 



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to