OpenGrok revision 979
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen# OpenGrok Wrapper (initial setup and cron job updating)
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen# Supported Operating Systems:
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen# - Solaris 10 (SunOS 5.10)
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen# - OpenSolaris (SunOS 5.11)
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen# - Debian (Linux)
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen# Supported Deployment Engines:
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen# - Tomcat 5.5
77bc2bda5b781c4ffddc8a74b175cf32e9e2c2ecTimo Sirainen# Supported Environment Variables:
77bc2bda5b781c4ffddc8a74b175cf32e9e2c2ecTimo Sirainen# - OPENGROK_NON_INTERACTIVE Suppress Progress and Warnings Messages (*)
77bc2bda5b781c4ffddc8a74b175cf32e9e2c2ecTimo Sirainen# - OPENGROK_STANDARD_ENV Run Time Shell Environment (Shell Script)
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen# - OPENGROK_CONFIGURATION User Configuration (Shell Script)
40a5aeebf6b4858b93f0ddff0bf12fba769cf903Timo Sirainen# Supported Environment Variables for configuring the default setup:
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen# - OPENGROK_DISTRIBUTION_BASE Base Directory of the OpenGrok Distribution
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen# - OPENGROK_INSTANCE_BASE Base Directory of the OpenGrok User Data Area
5da1aa5197a43d83f0fb3eeb83125c7cd73d1b62Timo Sirainen# - EXUBERANT_CTAGS Full Path to Exuberant CTags
5da1aa5197a43d83f0fb3eeb83125c7cd73d1b62Timo Sirainen# - JAVA_HOME Full Path to Java Installation Root
5da1aa5197a43d83f0fb3eeb83125c7cd73d1b62Timo Sirainen# - OPENGROK_APP_SERVER Application Server ("Tomcat" or "Glassfish")
4ee00532a265bdfb38539d811fcd12d51210ac35Timo Sirainen# - OPENGROK_WAR_TARGET_TOMCAT Tomcat Specific WAR Target Directory
5da1aa5197a43d83f0fb3eeb83125c7cd73d1b62Timo Sirainen# - OPENGROK_WAR_TARGET_GLASSFISH Glassfish Specific WAR Target Directory
5da1aa5197a43d83f0fb3eeb83125c7cd73d1b62Timo Sirainen# - OPENGROK_WAR_TARGET Fallback WAR Target Directory
5da1aa5197a43d83f0fb3eeb83125c7cd73d1b62Timo Sirainen# - OPENGROK_TOMCAT_BASE Base Directory for Tomcat (contains webapps)
5da1aa5197a43d83f0fb3eeb83125c7cd73d1b62Timo Sirainen# - OPENGROK_GLASSFISH_BASE Base Directory for Glassfish (contains domains)
5da1aa5197a43d83f0fb3eeb83125c7cd73d1b62Timo Sirainen# - OPENGROK_GLASSFISH_DOMAIN Preferred Glassfish Domain Name
5da1aa5197a43d83f0fb3eeb83125c7cd73d1b62Timo Sirainen# - OPENGROK_VERBOSE Enable Verbose Mode in opengrok.jar (*)
5da1aa5197a43d83f0fb3eeb83125c7cd73d1b62Timo Sirainen# - OPENGROK_REMOTE_REPOS Disable History Cache for (remote) Repositories (*)
5da1aa5197a43d83f0fb3eeb83125c7cd73d1b62Timo Sirainen# - OPENGROK_SCAN_REPOS Disable Scan for repositories (*)_
5da1aa5197a43d83f0fb3eeb83125c7cd73d1b62Timo Sirainen# - READ_XML_CONFIGURATION file with read only configuration - a temp workaround for bug # 327
5da1aa5197a43d83f0fb3eeb83125c7cd73d1b62Timo Sirainen# (*) Any Non-Empty String will enable these options
5da1aa5197a43d83f0fb3eeb83125c7cd73d1b62Timo Sirainen echo "Usage: ${0} <deploy|update|updateQuietly|usage>" 1>&2
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen echo " OPENGROK_CONFIGURATION - location of your configuration" 1>&2
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen echo " e.g. $ OPENGROK_CONFIGURATION=/var/opengrok/myog.conf ${0} ... " 1>&2
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen echo " See the code for more information on configuration options / variables" 1>&2
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen# Runtime Configuration
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen# TODO: Handle symlinks correctly (especially in ${0})
1279090ba03f9c176976a69ab7718f0ed77b19afTimo SirainenSCRIPT_DIRECTORY="`cd ${SCRIPT_DIRECTORY}; pwd`"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen# Default Instance Configuration
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # Use the built-in defaults. This section can be copied to its own
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # file and tailored to your local requirements. Then simply set
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # OPENGROK_CONFIGURATION=/path/to/your/configuration, before using
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # this wrapper. It will save you hand editing in your settings
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # on each new release. A sample cron(1M) entry might look like:
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # 15 0 * * * OPENGROK_CONFIGURATION=/pkgs/etc/OpenGrok.sh /pkgs/sbin/OpenGrok updateQuietly
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # Note: It is not really possible to ever provided defaults for
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # these values which will run in every UNIX-like environment.
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # So I have provided a set which are functional for a given
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # environment on which you can based you own configuration.
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # This has been updated to support more environment variables and
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # operating systems, if you have any reasonably generic
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # improvements please feel free to submit a patch.
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen OPENGROK_INSTANCE_BASE="${OPENGROK_INSTANCE_BASE:-/var/opengrok}"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen -f "${SCRIPT_DIRECTORY}/dist/opengrok.jar" -a \
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen OPENGROK_DISTRIBUTION_BASE="${SCRIPT_DIRECTORY}/dist"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen LOGGER_CONF_SOURCE="${SCRIPT_DIRECTORY}/${LOGGER_CONFIG_FILE}"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen OPENGROK_DISTRIBUTION_BASE="${SCRIPT_DIRECTORY}/../lib"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen LOGGER_CONF_SOURCE="${OPENGROK_DISTRIBUTION_BASE}/../doc/${LOGGER_CONFIG_FILE}"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # (your source code or the root of all repositories)
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # (for Lucene index and hypertext cross-references)
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # This area is rebuilt by "update" / "updateQuietly"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # OPTIONAL: User Provided Source Path to Description Mapping (Tab Separated Value)
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # (The user maintained source of the generated EftarFile file)
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen PATH_DESC="${OPENGROK_INSTANCE_BASE}/etc/paths.tsv"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # (the configuration used by Web/GUI interfaces)
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen XML_CONFIGURATION="${OPENGROK_INSTANCE_BASE}/etc/configuration.xml"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # OPTIONAL: read only XML config, if it exists, it will be read
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen READ_XML_CONFIGURATION="${READ_XML_CONFIGURATION:-}"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen LOGGER_CONFIG_PATH="${OPENGROK_INSTANCE_BASE}/${LOGGER_CONFIG_FILE}"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen LOGGER_PROPERTIES="-Djava.util.logging.config.file=${LOGGER_CONFIG_PATH}"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # REQUIRED: Java Archive of OpenGrok (Installation Location)
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen OPENGROK_JAR="${OPENGROK_DISTRIBUTION_BASE}/opengrok.jar"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # REQUIRED(deploy): Web Archive of OpenGrok (Distribution Location)
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # (user building from source code will find this and other key
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # files in the "dist" directory after the build is completed)
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen OPENGROK_DIST_WAR="${OPENGROK_DISTRIBUTION_BASE}/source.war"
77bc2bda5b781c4ffddc8a74b175cf32e9e2c2ecTimo Sirainen # REQUIRED: Exuberant CTags (http://ctags.sf.net)
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen EXUBERANT_CTAGS="${EXUBERANT_CTAGS:-`FindExuberantCTags`}"
e76f5e07be5bec4e5ca99c3e093ff7f11edbe1b7Timo Sirainen # DEVELOPMENT: Debug option, if enabled current indexer will listen on the port 8010 until a debugger connects
e76f5e07be5bec4e5ca99c3e093ff7f11edbe1b7Timo Sirainen #JAVA_DEBUG="-agentlib:jdwp=transport=dt_socket,server=y,address=8010,suspend=y"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # OPTIONAL: Ignore these patterns as names of files or directories
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # (Every directory in SRC_ROOT is considered a separate project)
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # OPTIONAL: Scanning Options (for Mercurial repositories)
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # OPTIONAL: Remote Repository Support (CVS or SVN)
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # (Can be very time demanding, uncomment if needed)
e76f5e07be5bec4e5ca99c3e093ff7f11edbe1b7Timo Sirainen # OPTIONAL: Set Maximum Indexed Words Per File
e76f5e07be5bec4e5ca99c3e093ff7f11edbe1b7Timo Sirainen # Note, that you might run out of memory, then either increase JVM memory
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # as noted in JAVA_OPTS, or set this limit(if you don't mind opengrok not
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # indexing the rest of the file, once the limit is reached)
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # Assumption: We should not set properties to the empty string
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen${HG:+-Dorg.opensolaris.opengrok.history.Mercurial=$HG} \
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen${CVS:+-Dorg.opensolaris.opengrok.history.cvs=$CVS} \
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen${SVN:+-Dorg.opensolaris.opengrok.history.Subversion=$SVN} \
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen${SCCS:+-Dorg.opensolaris.opengrok.history.SCCS=$SCCS} \
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen${CLEARCASE:+-Dorg.opensolaris.opengrok.history.ClearCase=$CLEARCASE} \
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen${GIT:+-Dorg.opensolaris.opengrok.history.git=$GIT} \
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen${P4:+-Dorg.opensolaris.opengrok.history.Perforce=$P4} \
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen${MTN:+-Dorg.opensolaris.opengrok.history.Monotone=$MTN} \
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen${BZR:+-Dorg.opensolaris.opengrok.history.Bazaar=$BZR} \
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # OPTIONAL: Store The History Cache in Java DB (derby),
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # instead of file system (in gzipped xml files).
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # - derbyclient.jar - See README.txt for more details
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # - Running Derby Server - Defaults to localhost:1527
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # Usage: <class> inputFile [inputFile ...] outputFile
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # EftarFile == An Extremely Fast Tagged Attribute Read-only File System
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen EFTAR_UPDATE="org.opensolaris.opengrok.web.EftarFile"
8e361d2906b0e44f7175a20981f8d2280645b58bTimo Sirainen # HARDCODED: Generated EftarFile (See web/*.jsp)
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen EFTAR_OUTPUT_FILE="${DATA_ROOT}/index/dtags.eftar"
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # Be Quiet? (set indirectly by command line arguments in the main program)
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen# Helper Functions - Logging
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen# In general, non-interactive use like cron jobs and automated
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen# installation environments should not generate unnecessary
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen# progress information or warnings, as usage and configuration
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen# will have generally been debugged prior to automation.
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen# Helper Functions - Autodetection of Runtime Environment
77bc2bda5b781c4ffddc8a74b175cf32e9e2c2ecTimo Sirainen Error "Unable to determine Exuberant CTags command name" \
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen SunOS:5.10) javaHome="/usr/jdk/instances/jdk1.6.0" ;;
77bc2bda5b781c4ffddc8a74b175cf32e9e2c2ecTimo Sirainen Linux:*) javaHome="/usr/lib/jvm/java-6-sun" ;;
77bc2bda5b781c4ffddc8a74b175cf32e9e2c2ecTimo Sirainen # Use this function to determine which environment the deploy the
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # web application function into. Some users (especially
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # developers) will have many deployment environments or will wish
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # to specify directly the application server to deploy to.
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # Either use the environment variable OPENGROK_APP_SERVER or
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # reimplement this function in your configuration file (as
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # This implementation favours Tomcat, but needs a lot of work,
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen # especially if Glassfish is perferrerd or it is under the control
8872e5c991430f96138a46e36b7f3c2c40d8e5c2Timo Sirainen # Maybe a better implementation would be to call Application
8872e5c991430f96138a46e36b7f3c2c40d8e5c2Timo Sirainen # Server specific WAR Directory and see if they exist.
77bc2bda5b781c4ffddc8a74b175cf32e9e2c2ecTimo Sirainen if [ -x "/etc/init.d/appserv" -a -d "/var/appserver/domains" ]
${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} ${JAVA} ${JAVA_OPTS} ${PROPERTIES} \
${LOGGER_PROPERTIES} \
${JAVA_DEBUG} \
-jar ${OPENGROK_JAR} \
${IGNORE_PATTERNS} ${ENABLE_PROJECTS} \
${DERBY_HISTORY_CACHE} \
${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}