OpenGrok revision d2a02e104622a26dd90fa88f4f17188f2039809f
c78c39caab4cf8b5daefc9c65878f7f5ed3eb7a0Tinderbox User# OpenGrok Wrapper (initial setup and cron job updating)
ab496cc3df1648e9ad992a87c35c2c0870fdc69dTinderbox User# Supported Operating Systems:
7c1468ed500356839a4a222517364e6ce18cb1a2Tinderbox User# - Solaris 10 (SunOS 5.10)
c57668a2fbbe558c1bd21652813616f2f517c469Tinderbox User# - OpenSolaris (SunOS 5.11)
a7c412f37cc73d0332887a746e81220cbf09dd00Mark Andrews# - Debian (Linux)
dedefc0bdbb4e6e39eeb98aa2fc6883efec2ddb0Mark Andrews# Supported Deployment Engines
dedefc0bdbb4e6e39eeb98aa2fc6883efec2ddb0Mark Andrews# Supported Environment Variables :
e676a596869d8a80a644c99a848afb53d1c5975eMark Andrews# - OPENGROK_NON_INTERACTIVE Suppress Progress and Warnings Messages
e676a596869d8a80a644c99a848afb53d1c5975eMark Andrews# - OPENGROK_STANDARD_ENV Run Time Shell Environment (Shell Script)
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# - OPENGROK_CONFIGURATION User Configuration (Shell Script)
a7c412f37cc73d0332887a746e81220cbf09dd00Mark Andrews# Supported Environment Variables for configuring the default setup
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# - OPENGROK_DISTRIBUTION_BASE Base Directory of the OpenGrok Distribution
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# - OPENGROK_INSTANCE_BASE Base Directory of the OpenGrok User Data Area
e676a596869d8a80a644c99a848afb53d1c5975eMark Andrews# - EXUBERANT_CTAGS Full Path to Exuberant CTags
e676a596869d8a80a644c99a848afb53d1c5975eMark Andrews# - JAVA_HOME Full Path to Java Installation Root
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# - OPENGROK_APP_SERVER Application Server ("Tomcat" or "Glassfish")
9ecb5d33470ebfb3719a1b8d56bcefdf4b27f7b2Tinderbox User# - OPENGROK_WAR_TARGET_TOMCAT Tomcat Specific WAR Target Directory
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews# - OPENGROK_WAR_TARGET_GLASSFISH Glassfish Specific WAR Target Directory
9ecb5d33470ebfb3719a1b8d56bcefdf4b27f7b2Tinderbox User# - OPENGROK_WAR_TARGET Fallback WAR Target Directory
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews# - OPENGROK_TOMCAT_BASE Base Directory for Tomcat (contains webapps)
9ecb5d33470ebfb3719a1b8d56bcefdf4b27f7b2Tinderbox User# - OPENGROK_GLASSFISH_BASE Base Directory for Glassfish (contains domains)
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews# - OPENGROK_GLASSFISH_DOMAIN Preferred Glassfish Domain Name
9ecb5d33470ebfb3719a1b8d56bcefdf4b27f7b2Tinderbox User echo "Usage: ${0} <deploy|update|updateQuietly|updateConfiguration|usage>" 1>&2
dedefc0bdbb4e6e39eeb98aa2fc6883efec2ddb0Mark Andrews echo " OPENGROK_CONFIGURATION - location of your configuartion" 1>&2
aa9c561961e9d877946ebaa8795fa2be054ab7bfEvan Hunt echo " e.g. $ OPENGROK_CONFIGURATION=/var/opengrok/myog.conf ${0} ... " 1>&2
0e573cdd111e060e5f6c18249b5ccacbe8abe278Tinderbox User echo " See the code for more information on configuration options" 1>&2
dc238a06bffa79de141ee7655765e2df91498a8aTinderbox User# Runtime Configuration
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews# Default Instance Configuration
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews # Use the built-in defaults. This section can be copied to its own
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater # file and tailored to your local requirements. Then simply set
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews # OPENGROK_CONFIGURATION=/path/to/your/configuration, before using
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews # this wrapper. It will save you hand editing in your settings
16f6050f29b6b0422cee858e609f65e474e70ef2Tinderbox User # on each new release. A sample cron(1M) entry might look like:
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews # 15 0 * * * OPENGROK_CONFIGURATION=/pkgs/etc/OpenGrok.sh /pkgs/sbin/OpenGrok updateQuietly
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews # Note: It is not really possible to ever provided defaults for
eabc9c3c07cd956d3c436bd7614cb162dabdda76Mark Andrews # these values which will run in every UNIX-like environment.
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews # So I have provided a set which are functional for a given
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews # environment on which you can based you own configuration.
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews # This has been updated to support more environment variables and
015055b6e23f5c08f6a5b34726f90b62597e9e45Tinderbox User # operating systems, if you have any reasonably generic
2ae159b376dac23870d8005563c585acf85a4b5aEvan Hunt # improvements please feel free to submit a patch.
e40c4e4c17d4df338e2a7db0f84d8dbb3858964cTinderbox User OPENGROK_INSTANCE_BASE="${OPENGROK_INSTANCE_BASE:-/var/opengrok}"
2ae159b376dac23870d8005563c585acf85a4b5aEvan Hunt if [ -d "dist" -a -f "dist/opengrok.jar" -a -f "dist/source.war" ]
e40c4e4c17d4df338e2a7db0f84d8dbb3858964cTinderbox User # (your source code or the root of all repositories)
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews # (for Lucene index and hypertext cross-references)
e40c4e4c17d4df338e2a7db0f84d8dbb3858964cTinderbox User # This area is rebuilt by "update" / "updateQuietly"
77932ac533c711eca5cd86de4e7eca8d91102b43Tinderbox User # OPTIONAL: User Provided Source Path to Description Mapping (Tab Separated Value)
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews # (The user maintained source of the generated EftarFile file)
9ecb5d33470ebfb3719a1b8d56bcefdf4b27f7b2Tinderbox User PATH_DESC="${OPENGROK_INSTANCE_BASE}/etc/paths.tsv"
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews # (the configuration used by Web/GUI interfaces)
9ecb5d33470ebfb3719a1b8d56bcefdf4b27f7b2Tinderbox User XML_CONFIGURATION="${OPENGROK_INSTANCE_BASE}/etc/configuration.xml"
9ecb5d33470ebfb3719a1b8d56bcefdf4b27f7b2Tinderbox User # REQUIRED: Java Archive of OpenGrok (Installation Location)
efb0e886f18894a1d2489f1ad74ad14b579e11c7Mark Andrews OPENGROK_JAR="${OPENGROK_INSTANCE_BASE}/opengrok.jar"
9ecb5d33470ebfb3719a1b8d56bcefdf4b27f7b2Tinderbox User # REQUIRED(deploy): Java Archive of OpenGrok (Distribution Location)
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews # (user building from source code will find this and other key
9ecb5d33470ebfb3719a1b8d56bcefdf4b27f7b2Tinderbox User # files in the "dist" directory after the build is completed)
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson OPENGROK_DIST_JAR="${OPENGROK_DISTRIBUTION_BASE}/opengrok.jar"
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews # REQUIRED(deploy): Web Archive of OpenGrok (Distribution Location)
9ecb5d33470ebfb3719a1b8d56bcefdf4b27f7b2Tinderbox User # (user building from source code will find this and other key
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews # files in the "dist" directory after the build is completed)
9ecb5d33470ebfb3719a1b8d56bcefdf4b27f7b2Tinderbox User OPENGROK_DIST_WAR="${OPENGROK_DISTRIBUTION_BASE}/source.war"
9ecb5d33470ebfb3719a1b8d56bcefdf4b27f7b2Tinderbox User # REQUIRED: Exuberant CTags (http://ctags.sf.net)
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews EXUBERANT_CTAGS="${EXUBERANT_CTAGS:-`FindExuberantCTags`}"
fd972434c29fc1169d66594e4cc7697d33036c2bTinderbox User # OPTIONAL: Scanning Options (for Mercurial repositories)
5747235bf35e7398984fd6b4632743396895ea7aTinderbox User # Assumption: We should not set properties to the empty string
78f3ed4bc2fcd3d270bfd599804f3b27a1db4d91Mark Andrews${HG:+-Dorg.opensolaris.opengrok.history.Mercurial=$HG} \
dedefc0bdbb4e6e39eeb98aa2fc6883efec2ddb0Mark Andrews${CVS:+-Dorg.opensolaris.opengrok.history.cvs=$CVS} \
dedefc0bdbb4e6e39eeb98aa2fc6883efec2ddb0Mark Andrews${SVN:+-Dorg.opensolaris.opengrok.history.Subversion=$SVN} \
78f3ed4bc2fcd3d270bfd599804f3b27a1db4d91Mark Andrews${SCCS:+-Dorg.opensolaris.opengrok.history.SCCS=$SCCS} \
dedefc0bdbb4e6e39eeb98aa2fc6883efec2ddb0Mark Andrews # Usage: <class> inputFile [inputFile ...] outputFile
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews # EftarFile == An Extremely Fast Tagged Attribute Read-only File System
e20788e1216ed720aefa84f3295f7899d9f28c22Mark Andrews EFTAR_UPDATE="org.opensolaris.opengrok.web.EftarFile"
dedefc0bdbb4e6e39eeb98aa2fc6883efec2ddb0Mark Andrews # HARDCODED: Generated EftarFile (See web/*.jsp)
01a5c5503482fb3ba52088bf0178a7213273bf96Mark Andrews EFTAR_OUTPUT_FILE="${DATA_ROOT}/index/dtags.eftar"
e40c4e4c17d4df338e2a7db0f84d8dbb3858964cTinderbox User # Be Quiet? (set indirectly by command line arguments in the main program)
9ecb5d33470ebfb3719a1b8d56bcefdf4b27f7b2Tinderbox User# Helper Functions - Logging
9ecb5d33470ebfb3719a1b8d56bcefdf4b27f7b2Tinderbox User# In general, non-interactive use like cron jobs and automated
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews# installation environments should not generate unnecessary
9ecb5d33470ebfb3719a1b8d56bcefdf4b27f7b2Tinderbox User# progress information or warnings, as usage and configuration
fa0326cc2cf428f67575b6ba3b97b528a31b0010Tinderbox User# will have generally been debugged prior to automation.
9ecb5d33470ebfb3719a1b8d56bcefdf4b27f7b2Tinderbox User# Helper Functions - Autodetection of Runtime Environment
933799f3641f4f78445d015008bad0038900a82aTinderbox User Error "Unable to determine Exuberant CTags command name" \
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews SunOS:5.10) javaHome="/usr/jdk/instances/jdk1.6.0" ;;
3ec8f7777ea2b04fc1ebb63077f0916f63b1011aTinderbox User Linux:*) javaHome="/usr/lib/jvm/java-6-sun/bin" ;;
4cda4fd158d6ded5586bacea8c388445d99611eaAutomatic Updater # Use this function to determine which environment the deploy the
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews # web application function into. Some users (especially
b02be031b9ff37b042adc8e68e36b8bbc1f672b7Tinderbox User # developers) will have many deployment environments or will wish
0e573cdd111e060e5f6c18249b5ccacbe8abe278Tinderbox User # to specify directly the application server to deploy to.
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater # Either use the environment variable OPENGROK_APP_SERVER or
e08cdffb3ae4ad409f37e3e5a218fe4b7e0e3904Tinderbox User # reimplement this function in your configuration file (as
933799f3641f4f78445d015008bad0038900a82aTinderbox User # This implementation favours Tomcat, but needs a lot of work,
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater # especially if Glassfish is perferrerd or it is under the control
da59e63e7af147a8bcef985b98b04443e04c3a0eTinderbox User # Maybe a better implementation would be to call Application
710bce1a85c96e85ca1a90471382055acd29d51fTinderbox User # Server specific WAR Directory and see if they exist.
dedefc0bdbb4e6e39eeb98aa2fc6883efec2ddb0Mark Andrews if [ -x "/etc/init.d/appserv" -a -d "/var/appserver/domains" ]
95c3a5e116c1da135f669c3f15398172fac6279dMark Andrews directory="${domainDirectory}/${OPENGROK_GLASSFISH_DOMAIN}/autodeploy"
d585233c52e283d9a8849f16f04f452419a2484eTinderbox User FatalError "Missing Specified Glassfish Domain ${OPENGROK_GLASSFISH_DOMAIN}"
0e573cdd111e060e5f6c18249b5ccacbe8abe278Tinderbox User firstDomain=`ls -1 ${domainDirectory} | head -1`
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater FatalError "Failed to dynamically determine Glassfish Domain from ${domainDirectory}"
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson echo "${domainDirectory}/${firstDomain}/autodeploy"
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews# Implementation
efb0e886f18894a1d2489f1ad74ad14b579e11c7Mark Andrews# The variable "DO" can usefully be set to "echo" to aid in script debugging
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington # Setup a standard execution environment (if required)
dedefc0bdbb4e6e39eeb98aa2fc6883efec2ddb0Mark Andrews OPENGROK_STANDARD_ENV="${OPENGROK_STANDARD_ENV:-/pkgs/sbin/CronExecutionEnvironment.sh}"
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews Progress "Loading ${OPENGROK_STANDARD_ENV} ..."
710bce1a85c96e85ca1a90471382055acd29d51fTinderbox User # Note: As all functions have been defined by the time this routine
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews # is called, your configuration can, if desired, override functions
a5636b773fa05a272b6876afd99309c0b3090e2fMark Andrews # in addition to setting the variables mentioned in the function
a5636b773fa05a272b6876afd99309c0b3090e2fMark Andrews # DefaultInstanceConfiguration(), this maybe useful to override
a5636b773fa05a272b6876afd99309c0b3090e2fMark Andrews # functionality used to determine the default deployment environment
a5636b773fa05a272b6876afd99309c0b3090e2fMark Andrews # find dependencies or validate the configuration, for example.
f7369b2881b5e63d69600adcedc8ba938303d30cTinderbox User if [ -n "${OPENGROK_CONFIGURATION}" -a -f "${OPENGROK_CONFIGURATION}" ]
d6317350b1180aa4517f2e8a92fa8fbcbf904ad8Automatic Updater # Load the Local OpenGrok Configuration Environment
bc0a4c01beede169df81a3ee5b614ed9e82339dbAutomatic Updater Progress "Loading ${OPENGROK_CONFIGURATION} ..."
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington Progress "Loading the default instance configuration ..."
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington FatalError "Missing Dependent Application - Exuberant CTags"
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington FatalError "OpenGrok Source Path ${SRC_ROOT} doesn't exist"
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington Warning "OpenGrok Generated Data Path ${DATA_ROOT} doesn't exist"
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington Progress " Attempting to create generated data directory ... "
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington ${SCAN_FOR_REPOSITORY} ${VERBOSE} ${QUIET} \
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington ${EXUBERANT_CTAGS:+-c} ${EXUBERANT_CTAGS} \
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews ${EFTAR_UPDATE} ${PATH_DESC} ${EFTAR_OUTPUT_FILE}
ae7e54b14c946e0984c191554db9abb4893f9349Automatic Updater ${DO} ${JAVA} ${JAVA_OPTS} -jar ${OPENGROK_JAR} '-?'
ae7e54b14c946e0984c191554db9abb4893f9349Automatic Updater applicationServer="`FindApplicationServerType`"
ae7e54b14c946e0984c191554db9abb4893f9349Automatic Updater Tomcat) warTarget="`DetermineWarDirectoryTomcat`" ;;
ae7e54b14c946e0984c191554db9abb4893f9349Automatic Updater Glassfish) warTarget="`DetermineWarDirectoryGlassfish`" ;;
c11c7b47726c02eb05e29ff7be56a3343146e396Tinderbox User *) FatalError "Unsupported Application Server ${applicationServer}" ;;
c11c7b47726c02eb05e29ff7be56a3343146e396Tinderbox User FatalError "Unable to determine Deployment Directory for ${applicationServer}"
c11c7b47726c02eb05e29ff7be56a3343146e396Tinderbox User FatalError "Missing Web Application Archive ${OPENGROK_DIST_WAR}"
c11c7b47726c02eb05e29ff7be56a3343146e396Tinderbox User FatalError "Missing Deployment Directory ${warTarget}"
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews Progress "Installing ${OPENGROK_DIST_WAR} to ${warTarget} ..."
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews ${DO} cp "${OPENGROK_DIST_WAR}" "${warTarget}/"
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews if [ $? != 0 ]
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews FatalError "Web Application Installation FAILED"
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater Progress "Start your application server (${applicationServer}), if it is not already"
febbdb34a7f7759922e239655e7429d78d3a8d26Tinderbox User Progress "running, or wait until it loads the just installed web application."
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater Progress "OpenGrok should be available on <HOST>:<PORT>/source"
dc238a06bffa79de141ee7655765e2df91498a8aTinderbox User Progress " where HOST and PORT are configured in ${applicationServer}."
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews# Main Program
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews# End of File