OpenGrok revision 789
8ec981fc8b0105da5f071e40811e0c2472a6c3c9Stéphane Graber# OpenGrok Wrapper (initial setup and cron job updating)
d2b2911c5530a5fec6e337a52ac906e14beea5f4Natanael Copa# Supported Operating Systems:
d2b2911c5530a5fec6e337a52ac906e14beea5f4Natanael Copa# - Solaris 10 (SunOS 5.10)
8ec981fc8b0105da5f071e40811e0c2472a6c3c9Stéphane Graber# - OpenSolaris (SunOS 5.11)
8ec981fc8b0105da5f071e40811e0c2472a6c3c9Stéphane Graber# - Debian (Linux)
8ec981fc8b0105da5f071e40811e0c2472a6c3c9Stéphane Graber# Supported Deployment Engines
d2b2911c5530a5fec6e337a52ac906e14beea5f4Natanael Copa# Supported Environment Variables :
d2b2911c5530a5fec6e337a52ac906e14beea5f4Natanael Copa# - OPENGROK_NON_INTERACTIVE Suppress Progress and Warnings Messages
207bf0e475f1dc6e9a2dac2cee3a209b56427855Stéphane Graber# - OPENGROK_STANDARD_ENV Run Time Shell Environment (Shell Script)
569bee5cc3d647032573db8f72734faa9307d577Natanael Copa# - OPENGROK_CONFIGURATION User Configuration (Shell Script)
6460d3c5f006d6cdae72e5c01e3a844986d20ff7Natanael Copa# Supported Environment Variables for configuring the default setup
6460d3c5f006d6cdae72e5c01e3a844986d20ff7Natanael Copa# - OPENGROK_DISTRIBUTION_BASE Base Directory of the OpenGrok Distribution
6460d3c5f006d6cdae72e5c01e3a844986d20ff7Natanael Copa# - OPENGROK_INSTANCE_BASE Base Directory of the OpenGrok User Data Area
6460d3c5f006d6cdae72e5c01e3a844986d20ff7Natanael Copa# - EXUBERANT_CTAGS Full Path to Exuberant CTags
569bee5cc3d647032573db8f72734faa9307d577Natanael Copa# - JAVA_HOME Full Path to Java Installation Root
569bee5cc3d647032573db8f72734faa9307d577Natanael Copa# - OPENGROK_APP_SERVER Application Server ("Tomcat" or "Glassfish")
85b41c7d7f72213199b5cff9525d17f44b49a842Kaarle Ritvanen# - OPENGROK_WAR_TARGET_TOMCAT Tomcat Specific WAR Target Directory
85b41c7d7f72213199b5cff9525d17f44b49a842Kaarle Ritvanen# - OPENGROK_WAR_TARGET_GLASSFISH Glassfish Specific WAR Target Directory
85b41c7d7f72213199b5cff9525d17f44b49a842Kaarle Ritvanen# - OPENGROK_WAR_TARGET Fallback WAR Target Directory
85b41c7d7f72213199b5cff9525d17f44b49a842Kaarle Ritvanen# - OPENGROK_TOMCAT_BASE Base Directory for Tomcat (contains webapps)
85b41c7d7f72213199b5cff9525d17f44b49a842Kaarle Ritvanen# - OPENGROK_GLASSFISH_BASE Base Directory for Glassfish (contains domains)
85b41c7d7f72213199b5cff9525d17f44b49a842Kaarle Ritvanen# - OPENGROK_GLASSFISH_DOMAIN Preferred Glassfish Domain Name
982e7b6ea40ea57923f4f094858424debc1a5f7fKaarle Ritvanen echo "Usage: ${0} <deploy|update|updateQuietly|updateConfiguration|usage>" 1>&2
982e7b6ea40ea57923f4f094858424debc1a5f7fKaarle Ritvanen echo " Optional environment variables:" 1>&2
982e7b6ea40ea57923f4f094858424debc1a5f7fKaarle Ritvanen echo " OPENGROK_CONFIGURATION - location of your configuartion" 1>&2
982e7b6ea40ea57923f4f094858424debc1a5f7fKaarle Ritvanen echo " e.g. $ OPENGROK_CONFIGURATION=/var/opengrok/myog.conf ${0} ... " 1>&2
85b41c7d7f72213199b5cff9525d17f44b49a842Kaarle Ritvanen echo " See the code for more information on configuration options" 1>&2
569bee5cc3d647032573db8f72734faa9307d577Natanael Copa# Runtime Configuration
569bee5cc3d647032573db8f72734faa9307d577Natanael Copa# Default Instance Configuration
569bee5cc3d647032573db8f72734faa9307d577Natanael Copa # Use the built-in defaults. This section can be copied to its own
569bee5cc3d647032573db8f72734faa9307d577Natanael Copa # file and tailored to your local requirements. Then simply set
569bee5cc3d647032573db8f72734faa9307d577Natanael Copa # OPENGROK_CONFIGURATION=/path/to/your/configuration, before using
569bee5cc3d647032573db8f72734faa9307d577Natanael Copa # this wrapper. It will save you hand editing in your settings
569bee5cc3d647032573db8f72734faa9307d577Natanael Copa # on each new release. A sample cron(1M) entry might look like:
569bee5cc3d647032573db8f72734faa9307d577Natanael Copa # 15 0 * * * OPENGROK_CONFIGURATION=/pkgs/etc/OpenGrok.sh /pkgs/sbin/OpenGrok updateQuietly
569bee5cc3d647032573db8f72734faa9307d577Natanael Copa # Note: It is not really possible to ever provided defaults for
569bee5cc3d647032573db8f72734faa9307d577Natanael Copa # these values which will run in every UNIX-like environment.
569bee5cc3d647032573db8f72734faa9307d577Natanael Copa # So I have provided a set which are functional for a given
569bee5cc3d647032573db8f72734faa9307d577Natanael Copa # environment on which you can based you own configuration.
569bee5cc3d647032573db8f72734faa9307d577Natanael Copa # This has been updated to support more environment variables and
569bee5cc3d647032573db8f72734faa9307d577Natanael Copa # operating systems, if you have any reasonably generic
569bee5cc3d647032573db8f72734faa9307d577Natanael Copa # improvements please feel free to submit a patch.
569bee5cc3d647032573db8f72734faa9307d577Natanael Copa OPENGROK_INSTANCE_BASE="${OPENGROK_INSTANCE_BASE:-/var/opengrok}"
569bee5cc3d647032573db8f72734faa9307d577Natanael Copa if [ -d "dist" -a -f "dist/opengrok.jar" -a -f "dist/source.war" ]
85b41c7d7f72213199b5cff9525d17f44b49a842Kaarle Ritvanen # (your source code or the root of all repositories)
2a9a0a08077d88ee1d70ca46ca122216f3d1c89aNatanael Copa # (for Lucene index and hypertext cross-references)
2a9a0a08077d88ee1d70ca46ca122216f3d1c89aNatanael Copa # This area is rebuilt by "update" / "updateQuietly"
569bee5cc3d647032573db8f72734faa9307d577Natanael Copa # OPTIONAL: User Provided Source Path to Description Mapping (Tab Separated Value)
569bee5cc3d647032573db8f72734faa9307d577Natanael Copa # (The user maintained source of the generated EftarFile file)
569bee5cc3d647032573db8f72734faa9307d577Natanael Copa PATH_DESC="${OPENGROK_INSTANCE_BASE}/etc/paths.tsv"
2a9a0a08077d88ee1d70ca46ca122216f3d1c89aNatanael Copa # (the configuration used by Web/GUI interfaces)
2a9a0a08077d88ee1d70ca46ca122216f3d1c89aNatanael Copa XML_CONFIGURATION="${OPENGROK_INSTANCE_BASE}/etc/configuration.xml"
2e599a6a25b533fe63840edc34ee265811b7b814Natanael Copa # REQUIRED: Java Archive of OpenGrok (Installation Location)
0b8cdc10346baebe63b5ed87d11182720a1f67bbKaarle Ritvanen OPENGROK_JAR="${OPENGROK_INSTANCE_BASE}/opengrok.jar"
2e599a6a25b533fe63840edc34ee265811b7b814Natanael Copa # REQUIRED(deploy): Java Archive of OpenGrok (Distribution Location)
2a9a0a08077d88ee1d70ca46ca122216f3d1c89aNatanael Copa # (user building from source code will find this and other key
2b49de9a3ff182c208148d780f6b26cf8cdd09d8Natanael Copa # files in the "dist" directory after the build is completed)
2b49de9a3ff182c208148d780f6b26cf8cdd09d8Natanael Copa OPENGROK_DIST_JAR="${OPENGROK_DISTRIBUTION_BASE}/opengrok.jar"
2b49de9a3ff182c208148d780f6b26cf8cdd09d8Natanael Copa # REQUIRED(deploy): Web Archive of OpenGrok (Distribution Location)
569bee5cc3d647032573db8f72734faa9307d577Natanael Copa # (user building from source code will find this and other key
2a9a0a08077d88ee1d70ca46ca122216f3d1c89aNatanael Copa # files in the "dist" directory after the build is completed)
2a9a0a08077d88ee1d70ca46ca122216f3d1c89aNatanael Copa OPENGROK_DIST_WAR="${OPENGROK_DISTRIBUTION_BASE}/source.war"
2a9a0a08077d88ee1d70ca46ca122216f3d1c89aNatanael Copa # REQUIRED: Exuberant CTags (http://ctags.sf.net)
2a9a0a08077d88ee1d70ca46ca122216f3d1c89aNatanael Copa EXUBERANT_CTAGS="${EXUBERANT_CTAGS:-`FindExuberantCTags`}"
2a9a0a08077d88ee1d70ca46ca122216f3d1c89aNatanael Copa # OPTIONAL: Scanning Options (for Mercurial repositories)
2a9a0a08077d88ee1d70ca46ca122216f3d1c89aNatanael Copa # Assumption: We should not set properties to the empty string
2a9a0a08077d88ee1d70ca46ca122216f3d1c89aNatanael Copa${HG:+-Dorg.opensolaris.opengrok.history.Mercurial=$HG} \
3d460a3856376a043b3fa9addee50f89d21fa747Natanael Copa${CVS:+-Dorg.opensolaris.opengrok.history.cvs=$CVS} \
2a9a0a08077d88ee1d70ca46ca122216f3d1c89aNatanael Copa${SVN:+-Dorg.opensolaris.opengrok.history.Subversion=$SVN} \
2a9a0a08077d88ee1d70ca46ca122216f3d1c89aNatanael Copa${SCCS:+-Dorg.opensolaris.opengrok.history.SCCS=$SCCS} \
2a9a0a08077d88ee1d70ca46ca122216f3d1c89aNatanael Copa # Usage: <class> inputFile [inputFile ...] outputFile
2a9a0a08077d88ee1d70ca46ca122216f3d1c89aNatanael Copa # EftarFile == An Extremely Fast Tagged Attribute Read-only File System
2a9a0a08077d88ee1d70ca46ca122216f3d1c89aNatanael Copa EFTAR_UPDATE="org.opensolaris.opengrok.web.EftarFile"
2a9a0a08077d88ee1d70ca46ca122216f3d1c89aNatanael Copa # HARDCODED: Generated EftarFile (See web/*.jsp)
48c63f8d035045af1103b677b5ec577aec59a5b5Natanael Copa EFTAR_OUTPUT_FILE="${DATA_ROOT}/index/dtags.eftar"
2a9a0a08077d88ee1d70ca46ca122216f3d1c89aNatanael Copa # Be Quiet? (set indirectly by command line arguments in the main program)
2a9a0a08077d88ee1d70ca46ca122216f3d1c89aNatanael Copa# Helper Functions - Logging
2a9a0a08077d88ee1d70ca46ca122216f3d1c89aNatanael Copa# In general, non-interactive use like cron jobs and automated
2a9a0a08077d88ee1d70ca46ca122216f3d1c89aNatanael Copa# installation environments should not generate unnecessary
2a9a0a08077d88ee1d70ca46ca122216f3d1c89aNatanael Copa# progress information or warnings, as usage and configuration
2899ab0b1a607e7824214590ebe93f76fa7f7c20Natanael Copa# will have generally been debugged prior to automation.
75b5535282453b3442a41df4a3ba6d3058cd6e48Natanael Copa# Helper Functions - Autodetection of Runtime Environment
2a9a0a08077d88ee1d70ca46ca122216f3d1c89aNatanael Copa Error "Unable to determine Exuberant CTags command name" \
2a9a0a08077d88ee1d70ca46ca122216f3d1c89aNatanael Copa SunOS:5.10) javaHome="/usr/jdk/instances/jdk1.6.0" ;;
2a9a0a08077d88ee1d70ca46ca122216f3d1c89aNatanael Copa Linux:*) javaHome="/usr/lib/jvm/java-6-sun/bin" ;;
982e7b6ea40ea57923f4f094858424debc1a5f7fKaarle Ritvanen # Use this function to determine which environment the deploy the
982e7b6ea40ea57923f4f094858424debc1a5f7fKaarle Ritvanen # web application function into. Some users (especially
1897e3bcd36af9f3fe6d3649910a9adb93e5e988Serge Hallyn # developers) will have many deployment environments or will wish
1897e3bcd36af9f3fe6d3649910a9adb93e5e988Serge Hallyn # to specify directly the application server to deploy to.
2a9a0a08077d88ee1d70ca46ca122216f3d1c89aNatanael Copa # Either use the environment variable OPENGROK_APP_SERVER or
2a9a0a08077d88ee1d70ca46ca122216f3d1c89aNatanael Copa # reimplement this function in your configuration file (as
2a9a0a08077d88ee1d70ca46ca122216f3d1c89aNatanael Copa # This implementation favours Tomcat, but needs a lot of work,
5be56973e5e874a142263dfb164b0b03e18a65f3Serge Hallyn # especially if Glassfish is perferrerd or it is under the control
5be56973e5e874a142263dfb164b0b03e18a65f3Serge Hallyn # Maybe a better implementation would be to call Application
5be56973e5e874a142263dfb164b0b03e18a65f3Serge Hallyn # Server specific WAR Directory and see if they exist.
2a9a0a08077d88ee1d70ca46ca122216f3d1c89aNatanael Copa if [ -x "/etc/init.d/appserv" -a -d "/var/appserver/domains" ]
${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}