OpenGrok revision d0767114e1a949e4a42358f5aeaa08590b87cd80
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# OpenGrok Wrapper (initial setup and cron job updating)
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# Supported Operating Systems:
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# - Solaris 10 (SunOS 5.10)
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# - OpenSolaris (SunOS 5.11)
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# - Debian (Linux)
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# Supported Deployment Engines:
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# - Tomcat 5.5
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# - Glassfish
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# Supported Environment Variables:
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# - OPENGROK_NON_INTERACTIVE Suppress Progress and Warnings Messages (*)
c247e3f281613fabe1af362e9f3157e35ebbe52cMark Andrews# - OPENGROK_STANDARD_ENV Run Time Shell Environment (Shell Script)
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# - OPENGROK_CONFIGURATION User Configuration (Shell Script)
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# Supported Environment Variables for configuring the default setup:
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# - OPENGROK_DISTRIBUTION_BASE Base Directory of the OpenGrok Distribution
e21a2904f02a03fa06b6db04d348f65fe9c67b2bMark Andrews# - OPENGROK_INSTANCE_BASE Base Directory of the OpenGrok User Data Area
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# - EXUBERANT_CTAGS Full Path to Exuberant CTags
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# - JAVA_HOME Full Path to Java Installation Root
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# - OPENGROK_APP_SERVER Application Server ("Tomcat" or "Glassfish")
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# - OPENGROK_WAR_TARGET_TOMCAT Tomcat Specific WAR Target Directory
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# - OPENGROK_WAR_TARGET_GLASSFISH Glassfish Specific WAR Target Directory
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# - OPENGROK_WAR_TARGET Fallback WAR Target Directory
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# - OPENGROK_TOMCAT_BASE Base Directory for Tomcat (contains webapps)
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# - OPENGROK_GLASSFISH_BASE Base Directory for Glassfish (contains domains)
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# - OPENGROK_GLASSFISH_DOMAIN Preferred Glassfish Domain Name
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# - OPENGROK_VERBOSE Enable Verbose Mode in opengrok.jar (*)
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# - OPENGROK_PROGRESS Shows progress in %(percentage) of working through project, it's good to have Verbose Mode enabled too, cost of this is one more traversal of the project before indexing it (*)
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# - OPENGROK_REMOTE_REPOS Disable History Cache for (remote) Repositories (*)
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# - OPENGROK_SCAN_REPOS Disable Scan for repositories (*)_
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# - OPENGROK_SCAN_DEPTH how deep should scanning for repos go (by default 3 directories from SRC_ROOT)
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# - OPENGROK_WPREFIX Disable wildcard prefix search query support (*)
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# - OPENGROK_DERBY if set, then indexer tries to use derby as historycache (see derby command of this script)
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# - READ_XML_CONFIGURATION file with read only configuration - a temp workaround for bug # 327
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# (*) Any Non-Empty String will enable these options
12351e0500dff39f56844401fd191a36bcc4a7adMark Andrews echo "Usage: ${0} <deploy|derby|update|updateQuietly|usage>" 1>&2
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews echo " OPENGROK_CONFIGURATION - location of your configuration" 1>&2
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews echo " e.g. $ OPENGROK_CONFIGURATION=/var/opengrok/myog.conf ${0} ... " 1>&2
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews echo " See the code for more information on configuration options / variables" 1>&2
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# Runtime Configuration
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# TODO: Handle symlinks correctly (especially in ${0})
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark AndrewsSCRIPT_DIRECTORY="`cd ${SCRIPT_DIRECTORY}; pwd`"
12351e0500dff39f56844401fd191a36bcc4a7adMark Andrews# Default Instance Configuration
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews # Use the built-in defaults. This section can be copied to its own
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews # file and tailored to your local requirements. Then simply set
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews # OPENGROK_CONFIGURATION=/path/to/your/configuration, before using
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews # this wrapper. It will save you hand editing in your settings
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews # on each new release. A sample cron(1M) entry might look like:
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews # 15 0 * * * OPENGROK_CONFIGURATION=/pkgs/etc/OpenGrok.sh /pkgs/sbin/OpenGrok updateQuietly
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews # Note: It is not really possible to ever provided defaults for
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews # these values which will run in every UNIX-like environment.
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews # So I have provided a set which are functional for a given
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews # environment on which you can based you own configuration.
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews # This has been updated to support more environment variables and
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews # operating systems, if you have any reasonably generic
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews # improvements please feel free to submit a patch.
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews OPENGROK_INSTANCE_BASE="${OPENGROK_INSTANCE_BASE:-/var/opengrok}"
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews -f "${SCRIPT_DIRECTORY}/dist/opengrok.jar" -a \
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews OPENGROK_DISTRIBUTION_BASE="${SCRIPT_DIRECTORY}/dist"
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews LOGGER_CONF_SOURCE="${SCRIPT_DIRECTORY}/${LOGGER_CONFIG_FILE}"
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews OPENGROK_DISTRIBUTION_BASE="${SCRIPT_DIRECTORY}/../lib"
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews LOGGER_CONF_SOURCE="${OPENGROK_DISTRIBUTION_BASE}/../doc/${LOGGER_CONFIG_FILE}"
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews # (your source code or the root of all repositories)
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews # (for Lucene index and hypertext cross-references)
c247e3f281613fabe1af362e9f3157e35ebbe52cMark Andrews # This area is rebuilt by "update" / "updateQuietly"
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews # OPTIONAL: User Provided Source Path to Description Mapping (Tab Separated Value)
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews # (The user maintained source of the generated EftarFile file)
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews PATH_DESC="${OPENGROK_INSTANCE_BASE}/etc/paths.tsv"
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews # (the configuration used by Web/GUI interfaces)
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews XML_CONFIGURATION="${OPENGROK_INSTANCE_BASE}/etc/configuration.xml"
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews # OPTIONAL: read only XML config, if it exists, it will be read
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews READ_XML_CONFIGURATION="${READ_XML_CONFIGURATION:-}"
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews LOGGER_CONFIG_PATH="${OPENGROK_INSTANCE_BASE}/${LOGGER_CONFIG_FILE}"
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews LOGGER_PROPERTIES="-Djava.util.logging.config.file=${LOGGER_CONFIG_PATH}"
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews # REQUIRED: Java Archive of OpenGrok (Installation Location)
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews OPENGROK_JAR="${OPENGROK_DISTRIBUTION_BASE}/opengrok.jar"
12351e0500dff39f56844401fd191a36bcc4a7adMark Andrews # REQUIRED(deploy): Web Archive of OpenGrok (Distribution Location)
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews # (user building from source code will find this and other key
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews # files in the "dist" directory after the build is completed)
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews OPENGROK_DIST_WAR="${OPENGROK_DISTRIBUTION_BASE}/source.war"
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews # REQUIRED: Exuberant CTags (http://ctags.sf.net)
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews EXUBERANT_CTAGS="${EXUBERANT_CTAGS:-`FindExuberantCTags`}"
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews # DEVELOPMENT: Debug option, if enabled current indexer will listen on the port 8010 until a debugger connects
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews #JAVA_DEBUG="-agentlib:jdwp=transport=dt_socket,server=y,address=8010,suspend=y"
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews # OPTIONAL: Ignore these patterns as names of files or directories
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews # (Every directory in SRC_ROOT is considered a separate project)
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews # OPTIONAL: Scanning Options (for Mercurial repositories)
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews # OPTIONAL: Remote Repository Support (CVS or SVN)
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews # (Can be very time demanding, uncomment if needed)
4abdfc917e6635a7c81d1f931a0c79227e72d025Mark Andrews # OPTIONAL: override depth of scanning for repositories
${CVS:+-Dorg.opensolaris.opengrok.history.cvs=$CVS} \
${SCCS:+-Dorg.opensolaris.opengrok.history.SCCS=$SCCS} \
${CLEARCASE:+-Dorg.opensolaris.opengrok.history.ClearCase=$CLEARCASE} \
${GIT:+-Dorg.opensolaris.opengrok.history.git=$GIT} \
${DO} exit 2
for f in $@
echo $file
if test $? -eq 1
if test $? -ne 0
echo ${binary}
Linux:*)
if [ -f /etc/alternatives/java ]
/usr/lib/jvm/sun-jre-1.6 \
${OPENGROK_TOMCAT_BASE} \
Warning "CHECK: derbyclient.jar needs to be in where the rest of opengrok used jars are and in unpacked source.war in WEB-INF/lib !!!"
${DO} grep -v java.util.logging.FileHandler.pattern "${LOGGER_CONF_SOURCE}" > "${LOGGER_CONFIG_PATH}"
${DO} grep java.util.logging.FileHandler.pattern "${LOGGER_CONF_SOURCE}" | sed "s|opengrok%g.%u.log|${OPENGROK_INSTANCE_BASE}/log/opengrok%g.%u.log|g" >> "${LOGGER_CONFIG_PATH}"
${DO} mkdir ${OPENGROK_INSTANCE_BASE}/log
${DO} mkdir -p ${OPENGROK_INSTANCE_BASE}/derby
${DO} ${JAVA} ${JAVA_OPTS} ${PROPERTIES} \
${LOGGER_PROPERTIES} \
${JAVA_DEBUG} \
-jar ${OPENGROK_JAR} \
${IGNORE_PATTERNS} ${ENABLE_PROJECTS} \
${DERBY_HISTORY_CACHE} \
${SCAN_DEPTH} \
${PROGRESS} \
${EXUBERANT_CTAGS:+-c} ${EXUBERANT_CTAGS} \
${MAX_INDEXED_WORDS} ${SKIN} ${LEADING_WILDCARD} \
${READ_XML_CONF} \
-W ${XML_CONFIGURATION} \
${DO} ${JAVA} -classpath ${OPENGROK_JAR} \
${EFTAR_UPDATE} ${PATH_DESC} ${EFTAR_OUTPUT_FILE}
SunOS:5.11)
Linux:*)
mkdir -p $DATA_ROOT/derby