OpenGrok revision d2a02e104622a26dd90fa88f4f17188f2039809f
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# - Glassfish
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# Supported Environment Variables :
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# - OPENGROK_NON_INTERACTIVE Suppress Progress and Warnings Messages
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# - OPENGROK_STANDARD_ENV Run Time Shell Environment (Shell Script)
c247e3f281613fabe1af362e9f3157e35ebbe52cMark 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
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# - OPENGROK_INSTANCE_BASE Base Directory of the OpenGrok User Data Area
e21a2904f02a03fa06b6db04d348f65fe9c67b2bMark 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 echo "Usage: ${0} <deploy|update|updateQuietly|updateConfiguration|usage>" 1>&2
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews echo " OPENGROK_CONFIGURATION - location of your configuartion" 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" 1>&2
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# Runtime Configuration
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark 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
c247e3f281613fabe1af362e9f3157e35ebbe52cMark 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 if [ -d "dist" -a -f "dist/opengrok.jar" -a -f "dist/source.war" ]
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews # (your source code or the root of all repositories)
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews # (for Lucene index and hypertext cross-references)
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark 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 # REQUIRED: Java Archive of OpenGrok (Installation Location)
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews OPENGROK_JAR="${OPENGROK_INSTANCE_BASE}/opengrok.jar"
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews # REQUIRED(deploy): Java 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_JAR="${OPENGROK_DISTRIBUTION_BASE}/opengrok.jar"
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark 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 # OPTIONAL: Scanning Options (for Mercurial repositories)
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews # Assumption: We should not set properties to the empty string
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews${HG:+-Dorg.opensolaris.opengrok.history.Mercurial=$HG} \
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews${CVS:+-Dorg.opensolaris.opengrok.history.cvs=$CVS} \
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews${SVN:+-Dorg.opensolaris.opengrok.history.Subversion=$SVN} \
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews${SCCS:+-Dorg.opensolaris.opengrok.history.SCCS=$SCCS} \
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews # Usage: <class> inputFile [inputFile ...] outputFile
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews # EftarFile == An Extremely Fast Tagged Attribute Read-only File System
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews EFTAR_UPDATE="org.opensolaris.opengrok.web.EftarFile"
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews # HARDCODED: Generated EftarFile (See web/*.jsp)
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews EFTAR_OUTPUT_FILE="${DATA_ROOT}/index/dtags.eftar"
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews # Be Quiet? (set indirectly by command line arguments in the main program)
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# Helper Functions - Logging
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# In general, non-interactive use like cron jobs and automated
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# installation environments should not generate unnecessary
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# progress information or warnings, as usage and configuration
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# will have generally been debugged prior to automation.
${DO} exit 2
${OPENGROK_TOMCAT_BASE} \
${DO} ${JAVA} ${JAVA_OPTS} ${PROPERTIES} \
-jar ${OPENGROK_JAR} \
${SCAN_FOR_REPOSITORY} ${VERBOSE} ${QUIET} \
${EXUBERANT_CTAGS:+-c} ${EXUBERANT_CTAGS} \
${DO} ${JAVA} -classpath ${OPENGROK_JAR} \
${EFTAR_UPDATE} ${PATH_DESC} ${EFTAR_OUTPUT_FILE}