OpenGrok revision d280c5e286f5b98be13237f52281ae5afdcf51b9
0ca9a2c194523c517c3aafe5758e217ac88d6baaLubos Kosco# OpenGrok Wrapper (initial setup and cron job updating)
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# Supported Operating Systems:
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - Solaris 10 (SunOS 5.10)
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - OpenSolaris (SunOS 5.11)
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - Debian (Linux)
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# Supported Deployment Engines
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - Glassfish
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# Supported Environment Variables :
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - OPENGROK_NON_INTERACTIVE Suppress Progress and Warnings Messages
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - OPENGROK_STANDARD_ENV Run Time Shell Environment (Shell Script)
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - OPENGROK_CONFIGURATION User Configuration (Shell Script)
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# Supported Environment Variables for configuring the default setup
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - OPENGROK_DISTRIBUTION_BASE Base Directory of the OpenGrok Distribution
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - OPENGROK_INSTANCE_BASE Base Directory of the OpenGrok User Data Area
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - EXUBERANT_CTAGS Full Path to Exuberant CTags
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - JAVA_HOME Full Path to Java Installation Root
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - OPENGROK_APP_SERVER Application Server ("Tomcat" or "Glassfish")
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - OPENGROK_WAR_TARGET_TOMCAT Tomcat Specific WAR Target Directory
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - OPENGROK_WAR_TARGET_GLASSFISH Glassfish Specific WAR Target Directory
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - OPENGROK_WAR_TARGET Fallback WAR Target Directory
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - OPENGROK_TOMCAT_BASE Base Directory for Tomcat (contains webapps)
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - OPENGROK_GLASSFISH_BASE Base Directory for Glassfish (contains domains)
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# - OPENGROK_GLASSFISH_DOMAIN Preferred Glassfish Domain Name
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray echo "Usage: ${0} <deploy|update|updateQuietly|updateConfiguration|usage>" 1>&2
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray echo " OPENGROK_CONFIGURATION - location of your configuartion" 1>&2
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray echo " e.g. $ OPENGROK_CONFIGURATION=/var/opengrok/myog.conf ${0} ... " 1>&2
5762c9f28c2246777be0e9d49cb29d9c0f49146dLubos Kosco echo " See the code for more information on configuration options / variables" 1>&2
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# Runtime Configuration
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray# TODO: Handle symlinks correctly (especially in ${0})
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# Default Instance Configuration
cd348e325366620fe047edcc849e3c9424828599Peter Bray # Use the built-in defaults. This section can be copied to its own
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # file and tailored to your local requirements. Then simply set
cd348e325366620fe047edcc849e3c9424828599Peter Bray # OPENGROK_CONFIGURATION=/path/to/your/configuration, before using
cd348e325366620fe047edcc849e3c9424828599Peter Bray # this wrapper. It will save you hand editing in your settings
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # on each new release. A sample cron(1M) entry might look like:
cd348e325366620fe047edcc849e3c9424828599Peter Bray # 15 0 * * * OPENGROK_CONFIGURATION=/pkgs/etc/OpenGrok.sh /pkgs/sbin/OpenGrok updateQuietly
cd348e325366620fe047edcc849e3c9424828599Peter Bray # Note: It is not really possible to ever provided defaults for
cd348e325366620fe047edcc849e3c9424828599Peter Bray # these values which will run in every UNIX-like environment.
cd348e325366620fe047edcc849e3c9424828599Peter Bray # So I have provided a set which are functional for a given
cd348e325366620fe047edcc849e3c9424828599Peter Bray # environment on which you can based you own configuration.
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # This has been updated to support more environment variables and
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # operating systems, if you have any reasonably generic
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # improvements please feel free to submit a patch.
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray OPENGROK_INSTANCE_BASE="${OPENGROK_INSTANCE_BASE:-/var/opengrok}"
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray OPENGROK_DISTRIBUTION_BASE="${SCRIPT_DIRECTORY}/dist"
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray LOGGER_CONF_SOURCE="${SCRIPT_DIRECTORY}/conf/${LOGGER_CONFIG_FILE}"
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray LOGGER_CONF_SOURCE="${OPENGROK_DISTRIBUTION_BASE}/doc/${LOGGER_CONFIG_FILE}"
cd348e325366620fe047edcc849e3c9424828599Peter Bray # (your source code or the root of all repositories)
cd348e325366620fe047edcc849e3c9424828599Peter Bray # (for Lucene index and hypertext cross-references)
cd348e325366620fe047edcc849e3c9424828599Peter Bray # This area is rebuilt by "update" / "updateQuietly"
cd348e325366620fe047edcc849e3c9424828599Peter Bray # OPTIONAL: User Provided Source Path to Description Mapping (Tab Separated Value)
cd348e325366620fe047edcc849e3c9424828599Peter Bray # (The user maintained source of the generated EftarFile file)
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray PATH_DESC="${OPENGROK_INSTANCE_BASE}/etc/paths.tsv"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray XML_CONFIGURATION="${OPENGROK_INSTANCE_BASE}/etc/configuration.xml"
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray # TODO: Verify that Logger Configuration is REQUIRED and not OPTIONAL
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray LOGGER_CONFIG_PATH="${OPENGROK_INSTANCE_BASE}/${LOGGER_CONFIG_FILE}"
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray LOGGER_PROPERTIES="-Djava.util.logging.config.file=${LOGGER_CONFIG_PATH}"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # REQUIRED: Java Archive of OpenGrok (Installation Location)
3aa0947feb67d3e8292d84776638be98dd97fdc3Lubos Kosco OPENGROK_JAR="${OPENGROK_DISTRIBUTION_BASE}/opengrok.jar"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # REQUIRED(deploy): Web Archive of OpenGrok (Distribution Location)
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # (user building from source code will find this and other key
cd348e325366620fe047edcc849e3c9424828599Peter Bray # files in the "dist" directory after the build is completed)
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray OPENGROK_DIST_WAR="${OPENGROK_DISTRIBUTION_BASE}/source.war"
cd348e325366620fe047edcc849e3c9424828599Peter Bray # REQUIRED: Exuberant CTags (http://ctags.sf.net)
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray EXUBERANT_CTAGS="${EXUBERANT_CTAGS:-`FindExuberantCTags`}"
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray # OPTIONAL: Ignore these patterns as names of files or directories
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray # (Every directory in SRC_ROOT is considered a separate project)
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # OPTIONAL: Scanning Options (for Mercurial repositories)
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray # OPTIONAL: Remote Repository Support (CVS or SVN)
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray # (Can be very time demanding, uncomment if needed)
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray # OPTIONAL: Increase Maximum Indexed Words Per File
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # Assumption: We should not set properties to the empty string
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray${HG:+-Dorg.opensolaris.opengrok.history.Mercurial=$HG} \
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray${CVS:+-Dorg.opensolaris.opengrok.history.cvs=$CVS} \
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray${SVN:+-Dorg.opensolaris.opengrok.history.Subversion=$SVN} \
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray${SCCS:+-Dorg.opensolaris.opengrok.history.SCCS=$SCCS} \
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray # OPTIONAL: Store The History Cache in Java DB (derby),
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray # - derbyclient.jar - See README.txt for more details
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray # - Running Derby Server - Defaults to localhost:1527
cd348e325366620fe047edcc849e3c9424828599Peter Bray # Usage: <class> inputFile [inputFile ...] outputFile
cd348e325366620fe047edcc849e3c9424828599Peter Bray # EftarFile == An Extremely Fast Tagged Attribute Read-only File System
cd348e325366620fe047edcc849e3c9424828599Peter Bray EFTAR_UPDATE="org.opensolaris.opengrok.web.EftarFile"
cd348e325366620fe047edcc849e3c9424828599Peter Bray EFTAR_OUTPUT_FILE="${DATA_ROOT}/index/dtags.eftar"
cd348e325366620fe047edcc849e3c9424828599Peter Bray # Be Quiet? (set indirectly by command line arguments in the main program)
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# Helper Functions - Logging
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# In general, non-interactive use like cron jobs and automated
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# installation environments should not generate unnecessary
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# progress information or warnings, as usage and configuration
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# will have generally been debugged prior to automation.
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# Helper Functions - Autodetection of Runtime Environment
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray Error "Unable to determine Exuberant CTags command name" \
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray SunOS:5.10) javaHome="/usr/jdk/instances/jdk1.6.0" ;;
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # Use this function to determine which environment the deploy the
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # web application function into. Some users (especially
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # developers) will have many deployment environments or will wish
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # to specify directly the application server to deploy to.
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # Either use the environment variable OPENGROK_APP_SERVER or
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # reimplement this function in your configuration file (as
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # This implementation favours Tomcat, but needs a lot of work,
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # especially if Glassfish is perferrerd or it is under the control
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # Maybe a better implementation would be to call Application
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # Server specific WAR Directory and see if they exist.
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray if [ -x "/etc/init.d/appserv" -a -d "/var/appserver/domains" ]
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray directory="${domainDirectory}/${OPENGROK_GLASSFISH_DOMAIN}/autodeploy"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray FatalError "Missing Specified Glassfish Domain ${OPENGROK_GLASSFISH_DOMAIN}"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray FatalError "Failed to dynamically determine Glassfish Domain from ${domainDirectory}"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray echo "${domainDirectory}/${firstDomain}/autodeploy"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray# Implementation
cd348e325366620fe047edcc849e3c9424828599Peter Bray# The variable "DO" can usefully be set to "echo" to aid in script debugging
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # Setup a standard execution environment (if required)
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray OPENGROK_STANDARD_ENV="${OPENGROK_STANDARD_ENV:-/pkgs/sbin/CronExecutionEnvironment.sh}"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # Note: As all functions have been defined by the time this routine
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # is called, your configuration can, if desired, override functions
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # in addition to setting the variables mentioned in the function
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # DefaultInstanceConfiguration(), this maybe useful to override
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # functionality used to determine the default deployment environment
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # find dependencies or validate the configuration, for example.
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray if [ -n "${OPENGROK_CONFIGURATION}" -a -f "${OPENGROK_CONFIGURATION}" ]
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray # Load the Local OpenGrok Configuration Environment
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray Progress "Loading the default instance configuration ..."
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray FatalError "Missing Dependent Application - Exuberant CTags"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray FatalError "OpenGrok Source Path ${SRC_ROOT} doesn't exist"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray Warning "OpenGrok Generated Data Path ${DATA_ROOT} doesn't exist"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray Progress " Attempting to create generated data directory ... "
3aa0947feb67d3e8292d84776638be98dd97fdc3Lubos Kosco FatalError "OpenGrok Data Path ${DATA_ROOT} doesn't exist"
3aa0947feb67d3e8292d84776638be98dd97fdc3Lubos Kosco Warning "OpenGrok Generated Etc Path ${OPENGROK_INSTANCE_BASE}/etc doesn't exist"
3aa0947feb67d3e8292d84776638be98dd97fdc3Lubos Kosco Progress " Attempting to create generated etc directory ... "
3aa0947feb67d3e8292d84776638be98dd97fdc3Lubos Kosco FatalError "OpenGrok Etc Path ${OPENGROK_INSTANCE_BASE}/etc doesn't exist"
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray if [ -n "${LOGGER_CONFIG_PATH}" -a ! -f "${LOGGER_CONFIG_PATH}" ]
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray Progress " Creating default ${LOGGER_CONFIG_PATH} ... "
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray FatalError "Can't find distribution logging configuration"
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray ${DO} cp "${LOGGER_CONF_SOURCE}" "${LOGGER_CONFIG_PATH}"
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray # TODO: Consider automatically setting the logging directory
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray ${MAX_INDEXED_WORDS} ${SKIN} ${LEADING_WILDCARD} \
5762c9f28c2246777be0e9d49cb29d9c0f49146dLubos Kosco#? -R ${XML_CONFIGURATION} \
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray StdInvocation -W ${XML_CONFIGURATION} ${WEBAPP_CONFIG_ADDRESS}
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray ${EFTAR_UPDATE} ${PATH_DESC} ${EFTAR_OUTPUT_FILE}
cd348e325366620fe047edcc849e3c9424828599Peter Bray ${DO} ${JAVA} ${JAVA_OPTS} -jar ${OPENGROK_JAR} '-?'
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray Tomcat) warTarget="`DetermineWarDirectoryTomcat`" ;;
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray Glassfish) warTarget="`DetermineWarDirectoryGlassfish`" ;;
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray *) FatalError "Unsupported Application Server ${applicationServer}" ;;
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray FatalError "Unable to determine Deployment Directory for ${applicationServer}"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray FatalError "Missing Web Application Archive ${OPENGROK_DIST_WAR}"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray FatalError "Missing Deployment Directory ${warTarget}"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray Progress "Installing ${OPENGROK_DIST_WAR} to ${warTarget} ..."
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray if [ $? != 0 ]
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray Progress "Start your application server (${applicationServer}), if it is not already"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray Progress "running, or wait until it loads the just installed web application."
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray Progress "OpenGrok should be available on <HOST>:<PORT>/source"
d2a02e104622a26dd90fa88f4f17188f2039809fPeter Bray Progress " where HOST and PORT are configured in ${applicationServer}."
cd348e325366620fe047edcc849e3c9424828599Peter Bray# Main Program
d280c5e286f5b98be13237f52281ae5afdcf51b9Peter Bray if [ -n "${2}" ]
cd348e325366620fe047edcc849e3c9424828599Peter Bray# End of File