libreccm-legacy/ccm-core/bin/ccm

131 lines
3.9 KiB
Bash

#!/bin/bash
# This script is a wrapper for calling the CCM commandline utilites
# used for maintence of a CCM installation.
# Variables for directories.
# The path are relative to the bin directory of the CCM installation. This
# means that this script has to be executed from the bin directory. If you
# want to use this script from another directory, or include it into your
# PATH, you have to adjust the paths.
CCM_LIB_DIR="../lib"
CCM_RES_DIR="./bundle/res/"
CCM_CLASS_DIR="../classes"
CCM_HOME_DIR="../.."
# We need CATALINA_HOME environment variable to access Tomcat's lib dir.
if [[ -z "$CATALINA_HOME" ]] ; then
echo CATALINE_HOME not set. Guessing ...
if [ -d /usr/share/tomcat ]
then
CATALINA_HOME="/usr/share/tomcat"
elif [ -d /opt/tomcat ]
then
CATALINA_HOME="/opt/tomcat"
elif [ -d /usr/share/tomcat8 ]
then
CATALINA_HOME="/usr/share/tomcat8"
elif [ -d /usr/share/tomcat-8 ]
then
CATALINA_HOME="/usr/share/tomcat-8"
elif [ -d /opt/tomcat8 ]
then
CATALINA_HOME="/opt/tomcat8"
elif [ -d /usr/share/tomcat7 ]
then
CATALINA_HOME="/usr/share/tomcat7"
elif [ -d /usr/share/tomcat-7 ]
then
CATALINA_HOME="/usr/share/tomcat-7"
elif [ -d /opt/tomcat7 ]
then
CATALINA_HOME="/opt/tomcat7"
elif [ -d /usr/share/tomcat6 ]
then
CATALINA_HOME="/usr/share/tomcat6"
elif [ -d /usr/share/tomcat-6 ]
then
CATALINA_HOME="/usr/share/tomcat-6"
elif [ -d /opt/tomcat6 ]
then
CATALINA_HOME="/opt/tomcat6"
else
echo
echo ===================================================
echo Environment variable CATALINA_HOME not set. We need
echo to know the location of Tomcat\'s lib directory.
echo So use
echo export CATALINA_HOME=/path/to/tomcat/installation
echo to point us to the correct location and run ccm
echo again.
echo ===================================================
echo
exit 1
fi
echo
echo Using CATALINA_HOME = $CATALINA_HOME
echo If this doesn\'t work use
echo export CATALINA_HOME=/path/to/tomcat/installation
echo to point us to the correct location.
echo
sleep 3
fi
CATALINA_LIB_DIR="${CATALINA_HOME}/lib"
# Script logic starts here
echo "checking if all paths are correct..."
files=$(ls ${CCM_LIB_DIR}/ccm-core*.jar 2> /dev/null | wc -l)
if [ "$files" == "0" ]
then
echo "Error: CCM_LIB_DIR is invalid \(no ccm-core*.jar file\(s\) in CCM_LIB_DIR\)."
exit 1
fi
if [ ! -d ${CCM_HOME_DIR}/WEB-INF ]
then
echo "Error: CCM_HOME_DIR path is invalid \(no WEB-INF directory in CCM_HOME_DIR\)."
exit 1
fi
if [ ! -f ${CATALINA_LIB_DIR}/catalina.jar ]
then
echo "Error: CATALINA_LIB_DIR is invalid \(no catalina.jar in CATALINA_LIB_DIR\)."
exit 1
fi
#Convert to absolute path:
CCM_HOME_DIR=`cd ${CCM_HOME_DIR}; pwd`
#Constructing classpath
CCM_CLASSPATH="${CCM_LIB_DIR}/*:${CATALINA_LIB_DIR}/*:${CCM_RES_DIR}:${CCM_CLASS_DIR}/"
echo "Classpath is: $CCM_CLASSPATH"
# Handling DEBUGGING request
# The parameter MUST be the first!
if [ "$1" = "-D" ] ; then
echo "Activating debug mode, waiting for debugger to attach after CCM-Tool startup."
debug="-Xdebug -Xnoagent -Djava.compiler.NONE -Xrunjdwp:transport=dt_socket,server=y,address=8000,suspend=y "
shift
else
debug=""
fi
echo "Starting CCM-Tool..."
if [ "$1" = "prepare" ] ; then
echo
echo =====================================
echo $1:
echo - Initializes ccm after installation.
echo - Execute only ONCE!
echo =====================================
echo
param="load --interactive --packagekeys-file bundle/cfg/package-key.list --parameter-file bundle/cfg/integration.properties"
java $debug -cp $CCM_CLASSPATH -Dccm.home=${CCM_HOME_DIR} "com.arsdigita.packaging.MasterTool" $param
else
java $debug -cp $CCM_CLASSPATH -Dccm.home=${CCM_HOME_DIR} "com.arsdigita.packaging.MasterTool" "$@"
fi