1 #!/bin/sh 2 # 3 # OpenGrok Wrapper (initial setup and cron job updating) 4 # 5 # Supported Operating Systems: 6 # - Solaris 10 (SunOS 5.10) 7 # - OpenSolaris (SunOS 5.11) 8 # - Debian (Linux) 9 # 10 # Supported Deployment Engines: 11 # - Tomcat 6 12 # - Tomcat 5.5 13 # - Glassfish 14 # 15 # Supported Environment Variables: 16 # - OPENGROK_NON_INTERACTIVE Suppress Progress and Warnings Messages (*) 17 # - OPENGROK_STANDARD_ENV Run Time Shell Environment (Shell Script) 18 # - OPENGROK_CONFIGURATION User Configuration (Shell Script) 19 # 20 # Supported Environment Variables for configuring the default setup: 21 # - OPENGROK_DISTRIBUTION_BASE Base Directory of the OpenGrok Distribution 22 # - OPENGROK_INSTANCE_BASE Base Directory of the OpenGrok User Data Area 23 # - EXUBERANT_CTAGS Full Path to Exuberant CTags 24 # - JAVA_HOME Full Path to Java Installation Root 25 # - OPENGROK_APP_SERVER Application Server ("Tomcat" or "Glassfish") 26 # - OPENGROK_WAR_TARGET_TOMCAT Tomcat Specific WAR Target Directory 27 # - OPENGROK_WAR_TARGET_GLASSFISH Glassfish Specific WAR Target Directory 28 # - OPENGROK_WAR_TARGET Fallback WAR Target Directory 29 # - OPENGROK_TOMCAT_BASE Base Directory for Tomcat (contains webapps) 30 # - OPENGROK_GLASSFISH_BASE Base Directory for Glassfish (contains domains) 31 # - OPENGROK_GLASSFISH_DOMAIN Preferred Glassfish Domain Name 32 # - OPENGROK_VERBOSE Enable Verbose Mode in opengrok.jar (*) 33 # - OPENGROK_REMOTE_REPOS Disable History Cache for (remote) Repositories (*) 34 # - OPENGROK_SCAN_REPOS Disable Scan for repositories (*)_ 35 # - OPENGROK_SCAN_DEPTH how deep should scanning for repos go (by default 3 directories from SRC_ROOT) 36 # 37 # - READ_XML_CONFIGURATION file with read only configuration - a temp workaround for bug # 327 38 # 39 # Notes: 40 # (*) Any Non-Empty String will enable these options 41 # 42 43 # 44 # Usage 45 # 46 47 Usage() 48 { 49 echo 1>&2 50 echo "Usage: ${0} <deploy|update|updateQuietly|usage>" 1>&2 51 echo " ${0} index [<directory>]" 1>&2 52 echo 1>&2 53 echo " Optional environment variables:" 1>&2 54 echo " OPENGROK_CONFIGURATION - location of your configuration" 1>&2 55 echo " e.g. $ OPENGROK_CONFIGURATION=/var/opengrok/myog.conf ${0} ... " 1>&2 56 echo 1>&2 57 echo " See the code for more information on configuration options / variables" 1>&2 58 echo 1>&2 59 exit 1 60 } 61 62 # 63 # Runtime Configuration 64 # 65 66 OS_NAME="`/bin/uname -s`" 67 OS_VERSION="`/bin/uname -r`" 68 69 # TODO: Handle symlinks correctly (especially in ${0}) 70 SCRIPT_DIRECTORY="`dirname ${0}`" 71 SCRIPT_DIRECTORY="`cd ${SCRIPT_DIRECTORY}; pwd`" 72 73 # 74 # Default Instance Configuration 75 # 76 77 DefaultInstanceConfiguration() 78 { 79 # Use the built-in defaults. This section can be copied to its own 80 # file and tailored to your local requirements. Then simply set 81 # OPENGROK_CONFIGURATION=/path/to/your/configuration, before using 82 # this wrapper. It will save you hand editing in your settings 83 # on each new release. A sample cron(1M) entry might look like: 84 # 15 0 * * * OPENGROK_CONFIGURATION=/pkgs/etc/OpenGrok.sh /pkgs/sbin/OpenGrok updateQuietly 85 86 # Note: It is not really possible to ever provided defaults for 87 # these values which will run in every UNIX-like environment. 88 # So I have provided a set which are functional for a given 89 # environment on which you can based you own configuration. 90 91 # This has been updated to support more environment variables and 92 # operating systems, if you have any reasonably generic 93 # improvements please feel free to submit a patch. 94 95 OPENGROK_INSTANCE_BASE="${OPENGROK_INSTANCE_BASE:-/var/opengrok}" 96 97 LOGGER_CONFIG_FILE="logging.properties" 98 99 if [ -z "${OPENGROK_DISTRIBUTION_BASE}" ] 100 then 101 if [ -d "${SCRIPT_DIRECTORY}/dist" -a \ 102 -f "${SCRIPT_DIRECTORY}/dist/opengrok.jar" -a \ 103 -f "${SCRIPT_DIRECTORY}/dist/source.war" \ 104 ] 105 then 106 # Handle Developer Build Environments 107 OPENGROK_DISTRIBUTION_BASE="${SCRIPT_DIRECTORY}/dist" 108 LOGGER_CONF_SOURCE="${SCRIPT_DIRECTORY}/${LOGGER_CONFIG_FILE}" 109 else 110 # Handle Binary Distributions 111 OPENGROK_DISTRIBUTION_BASE="${SCRIPT_DIRECTORY}/../lib" 112 LOGGER_CONF_SOURCE="${OPENGROK_DISTRIBUTION_BASE}/../doc/${LOGGER_CONFIG_FILE}" 113 fi 114 fi 115 116 # REQUIRED: Source Code/Repository Root 117 # (your source code or the root of all repositories) 118 SRC_ROOT="${OPENGROK_INSTANCE_BASE}/src" 119 120 # REQUIRED: OpenGrok Generate Data Root 121 # (for Lucene index and hypertext cross-references) 122 # This area is rebuilt by "update" / "updateQuietly" 123 DATA_ROOT="${OPENGROK_INSTANCE_BASE}/data" 124 125 # OPTIONAL: User Provided Source Path to Description Mapping (Tab Separated Value) 126 # (The user maintained source of the generated EftarFile file) 127 PATH_DESC="${OPENGROK_INSTANCE_BASE}/etc/paths.tsv" 128 129 # REQUIRED: XML Configuration 130 # (the configuration used by Web/GUI interfaces) 131 XML_CONFIGURATION="${OPENGROK_INSTANCE_BASE}/etc/configuration.xml" 132 133 # OPTIONAL: read only XML config, if it exists, it will be read 134 READ_XML_CONFIGURATION="${READ_XML_CONFIGURATION:-}" 135 136 if [ -f "${READ_XML_CONFIGURATION}" ] ; then 137 READ_XML_CONF="-R ${READ_XML_CONFIGURATION}" 138 fi 139 140 # REQUIRED: Logger Configuration 141 LOGGER_CONFIG_PATH="${OPENGROK_INSTANCE_BASE}/${LOGGER_CONFIG_FILE}" 142 LOGGER_PROPERTIES="-Djava.util.logging.config.file=${LOGGER_CONFIG_PATH}" 143 144 # REQUIRED: Java Archive of OpenGrok (Installation Location) 145 OPENGROK_JAR="${OPENGROK_DISTRIBUTION_BASE}/opengrok.jar" 146 147 # REQUIRED(deploy): Web Archive of OpenGrok (Distribution Location) 148 # (user building from source code will find this and other key 149 # files in the "dist" directory after the build is completed) 150 OPENGROK_DIST_WAR="${OPENGROK_DISTRIBUTION_BASE}/source.war" 151 152 # REQUIRED: Exuberant CTags (http://ctags.sf.net) 153 EXUBERANT_CTAGS="${EXUBERANT_CTAGS:-`FindExuberantCTags`}" 154 155 # REQUIRED: Java Home 156 JAVA_HOME="${JAVA_HOME:-`FindJavaHome`}" 157 export JAVA_HOME 158 159 # REQUIRED: Java Virtual Machine 160 JAVA="${JAVA:-$JAVA_HOME/bin/java}" 161 162 # DEVELOPMENT: Debug option, if enabled current indexer will listen on the port 8010 until a debugger connects 163 #JAVA_DEBUG="-agentlib:jdwp=transport=dt_socket,server=y,address=8010,suspend=y" 164 165 # OPTIONAL: Ignore these patterns as names of files or directories 166 #IGNORE_PATTERNS="-i dummy" 167 168 # OPTIONAL: Enable Projects 169 # (Every directory in SRC_ROOT is considered a separate project) 170 ENABLE_PROJECTS="-P" 171 172 # OPTIONAL: Scanning Options (for Mercurial repositories) 173 SCAN_FOR_REPOSITORY="-S" 174 if [ ! -z "${OPENGROK_SCAN_REPOS}" ] 175 then 176 SCAN_FOR_REPOSITORY="" 177 fi 178 179 # OPTIONAL: Remote Repository Support (CVS or SVN) 180 # (Can be very time demanding, uncomment if needed) 181 REMOTE_REPOSITORIES="-r on" 182 if [ ! -z "${OPENGROK_REMOTE_REPOS}" ] 183 then 184 REMOTE_REPOSITORIES="" 185 fi 186 187 # OPTIONAL: override depth of scanning for repositories 188 if [ ! -z "${OPENGROK_SCAN_DEPTH}" ] 189 then 190 SCAN_DEPTH="-z${OPENGROK_SCAN_DEPTH}" 191 fi 192 193 # OPTIONAL: Allow Leading Wildcard Searches 194 # (default: off) 195 #LEADING_WILDCARD="-a on" 196 197 # OPTIONAL: Web Site Look & Feel 198 # (Options: default, offwhite and polished. 199 # Note the quoting requirements) 200 #SKIN='-L "default"' 201 202 # OPTIONAL: Set Maximum Indexed Words Per File 203 # Note, that you might run out of memory, then either increase JVM memory 204 # as noted in JAVA_OPTS, or set this limit(if you don't mind opengrok not 205 # indexing the rest of the file, once the limit is reached) 206 # (default: unlimited) 207 #MAX_INDEXED_WORDS="-m 100000" 208 209 # OPTIONAL: Configuration Address (host:port) 210 # (conf/web.xml default is localhost:2424) 211 WEBAPP_CONFIG_ADDRESS="-U localhost:2424" 212 213 # OPTIONAL: JVM Options 214 #JAVA_OPTS="-server -Xmx2048m" 215 JAVA_OPTS="-Xmx2048m" 216 217 # OPTIONAL: Full Path to History Utilities 218 HG="`Which hg`" 219 CVS="`Which cvs`" 220 SVN="`Which svn`" 221 SCCS="`Which sccs`" 222 CLEARCASE="`Which cleartool`" 223 GIT="`Which git`" 224 P4="`Which p4`" 225 MTN="`Which mtn`" 226 BZR="`Which bzr`" 227 228 # OPTIONAL: Override Built-in Properties 229 # Assumption: We should not set properties to the empty string 230 PROPERTIES="\ 231 ${HG:+-Dorg.opensolaris.opengrok.history.Mercurial=$HG} \ 232 ${CVS:+-Dorg.opensolaris.opengrok.history.cvs=$CVS} \ 233 ${SVN:+-Dorg.opensolaris.opengrok.history.Subversion=$SVN} \ 234 ${SCCS:+-Dorg.opensolaris.opengrok.history.SCCS=$SCCS} \ 235 ${CLEARCASE:+-Dorg.opensolaris.opengrok.history.ClearCase=$CLEARCASE} \ 236 ${GIT:+-Dorg.opensolaris.opengrok.history.git=$GIT} \ 237 ${P4:+-Dorg.opensolaris.opengrok.history.Perforce=$P4} \ 238 ${MTN:+-Dorg.opensolaris.opengrok.history.Monotone=$MTN} \ 239 ${BZR:+-Dorg.opensolaris.opengrok.history.Bazaar=$BZR} \ 240 " 241 242 # OPTIONAL: Store The History Cache in Java DB (derby), 243 # instead of file system (in gzipped xml files). 244 # 245 # Requirements: 246 # - derbyclient.jar - See README.txt for more details 247 # - Running Derby Server - Defaults to localhost:1527 248 # 249 #DERBY_HISTORY_CACHE=-D 250 251 # DELIVERED: An update program for EftarFile 252 # Usage: <class> inputFile [inputFile ...] outputFile 253 # EftarFile == An Extremely Fast Tagged Attribute Read-only File System 254 EFTAR_UPDATE="org.opensolaris.opengrok.web.EftarFile" 255 256 # HARDCODED: Generated EftarFile (See web/*.jsp) 257 EFTAR_OUTPUT_FILE="${DATA_ROOT}/index/dtags.eftar" 258 259 # Be Quiet? (set indirectly by command line arguments in the main program) 260 #QUIET="" 261 262 # or alternatively, Be Verbose! 263 #VERBOSE="-v" 264 265 if [ ! -z "${OPENGROK_VERBOSE}" ] 266 then 267 VERBOSE="-v" 268 QUIET="" 269 fi 270 } 271 272 # 273 # Helper Functions - Logging 274 # 275 # In general, non-interactive use like cron jobs and automated 276 # installation environments should not generate unnecessary 277 # progress information or warnings, as usage and configuration 278 # will have generally been debugged prior to automation. 279 # 280 281 Progress() 282 { 283 if [ -z "${OPENGROK_NON_INTERACTIVE}" ] 284 then 285 echo "${@}" 286 fi 287 } 288 289 Warning() 290 { 291 if [ -z "${OPENGROK_NON_INTERACTIVE}" ] 292 then 293 echo "WARNING: ${@}" 1>&2 294 fi 295 } 296 297 Error() 298 { 299 echo "ERROR: ${@}" 1>&2 300 } 301 302 FatalError() 303 { 304 echo 1>&2 305 echo "FATAL ERROR: ${@} - Aborting!" 1>&2 306 echo 1>&2 307 ${DO} exit 2 308 } 309 310 # 311 # Helper Functions - Autodetection of Runtime Environment 312 # 313 314 Which() 315 { 316 path="`which ${1} 2>/dev/null`" 317 318 if [ -x "${path}" ] 319 then 320 echo "${path}" 321 fi 322 } 323 324 FindExuberantCTags() 325 { 326 case "${OS_NAME}:${OS_VERSION}" in 327 SunOS:5.10) commandName="" ;; 328 SunOS:5.11) commandName="exctags" ;; 329 Linux:*) commandName="ctags-exuberant" ;; 330 *) commandName="" ;; 331 esac 332 333 if [ -z "${commandName}" ] 334 then 335 Error "Unable to determine Exuberant CTags command name" \ 336 "for ${OS_NAME} ${OS_VERSION}" 337 return 338 fi 339 340 Which "${commandName}" 341 } 342 343 FindJavaHome() 344 { 345 case "${OS_NAME}:${OS_VERSION}" in 346 SunOS:5.10) javaHome="/usr/jdk/instances/jdk1.6.0" ;; 347 SunOS:5.11) javaHome="/usr/jdk/latest" ;; 348 Linux:*) javaHome="/usr/lib/jvm/java-6-sun" ;; 349 *) javaHome="" ;; 350 esac 351 352 if [ -z "${javaHome}" ] 353 then 354 Error "Unable to determine Java 6 Home" \ 355 "for ${OS_NAME} ${OS_VERSION}" 356 return 357 fi 358 359 if [ ! -d "${javaHome}" ] 360 then 361 Error "Missing Java Home ${javaHome}" 362 return 363 fi 364 365 echo "${javaHome}" 366 } 367 368 FindApplicationServerType() 369 { 370 # Use this function to determine which environment the deploy the 371 # web application function into. Some users (especially 372 # developers) will have many deployment environments or will wish 373 # to specify directly the application server to deploy to. 374 375 # Either use the environment variable OPENGROK_APP_SERVER or 376 # reimplement this function in your configuration file (as 377 # specified by OPENGROK_CONFIGURATION) 378 379 if [ -n "${OPENGROK_APP_SERVER}" ] 380 then 381 echo "${OPENGROK_APP_SERVER}" 382 return 383 fi 384 385 # This implementation favours Tomcat, but needs a lot of work, 386 # especially if Glassfish is perferrerd or it is under the control 387 # of SMF (Service Management Facility) 388 389 # Maybe a better implementation would be to call Application 390 # Server specific WAR Directory and see if they exist. 391 392 if [ -d "/var/tomcat6/webapps" \ 393 -o -d "/var/lib/tomcat6/webapps" \ 394 -o -d "/var/lib/tomcat5.5/webapps" \ 395 ] 396 then 397 echo "Tomcat" 398 return 399 fi 400 401 if [ -x "/etc/init.d/appserv" -a -d "/var/appserver/domains" ] 402 then 403 echo "Glassfish" 404 return 405 fi 406 407 # Assume Tomcat 408 echo "Tomcat" 409 } 410 411 DetermineWarDirectoryTomcat() 412 { 413 if [ -n "${OPENGROK_WAR_TARGET_TOMCAT}" ] 414 then 415 echo "${OPENGROK_WAR_TARGET_TOMCAT}" 416 return 417 elif [ -n "${OPENGROK_WAR_TARGET}" ] 418 then 419 echo "${OPENGROK_WAR_TARGET}" 420 return 421 fi 422 423 for prefix in \ 424 ${OPENGROK_TOMCAT_BASE} \ 425 /var/tomcat6 \ 426 /var/lib/tomcat6 \ 427 /var/lib/tomcat5.5 \ 428 429 do 430 if [ -d "${prefix}/webapps" ] 431 then 432 echo "${prefix}/webapps" 433 return 434 fi 435 done 436 } 437 438 DetermineWarDirectoryGlassfish() 439 { 440 441 if [ -n "${OPENGROK_WAR_TARGET_GLASSFISH}" ] 442 then 443 echo "${OPENGROK_WAR_TARGET_GLASSFISH}" 444 return 445 elif [ -n "${OPENGROK_WAR_TARGET}" ] 446 then 447 echo "${OPENGROK_WAR_TARGET}" 448 return 449 fi 450 451 for prefix in \ 452 ${OPENGROK_GLASSFISH_BASE} \ 453 /var/appserver \ 454 455 do 456 if [ -d "${prefix}/domains" ] 457 then 458 if [ -z "${domainDirectory}" ] 459 then 460 domainDirectory="${prefix}/domains" 461 fi 462 fi 463 done 464 465 if [ -z "${domainDirectory}" ] 466 then 467 return 468 fi 469 470 # User Specified Domain 471 if [ -n "${OPENGROK_GLASSFISH_DOMAIN}" ] 472 then 473 directory="${domainDirectory}/${OPENGROK_GLASSFISH_DOMAIN}/autodeploy" 474 475 if [ ! -d "${directory}" ] 476 then 477 FatalError "Missing Specified Glassfish Domain ${OPENGROK_GLASSFISH_DOMAIN}" 478 fi 479 480 echo "${directory}" 481 return 482 fi 483 484 # Arbitrary Domain Selection 485 firstDomain=`ls -1 ${domainDirectory} | head -1` 486 487 if [ -z "${firstDomain}" ] 488 then 489 FatalError "Failed to dynamically determine Glassfish Domain from ${domainDirectory}" 490 fi 491 492 echo "${domainDirectory}/${firstDomain}/autodeploy" 493 } 494 495 # 496 # Implementation 497 # 498 # The variable "DO" can usefully be set to "echo" to aid in script debugging 499 # 500 501 LoadStandardEnvironment() 502 { 503 # Setup a standard execution environment (if required) 504 505 OPENGROK_STANDARD_ENV="${OPENGROK_STANDARD_ENV:-/pkgs/sbin/CronExecutionEnvironment.sh}" 506 507 if [ -f "${OPENGROK_STANDARD_ENV}" ] 508 then 509 Progress "Loading ${OPENGROK_STANDARD_ENV} ..." 510 . "${OPENGROK_STANDARD_ENV}" 511 fi 512 } 513 514 LoadInstanceConfiguration() 515 { 516 # Note: As all functions have been defined by the time this routine 517 # is called, your configuration can, if desired, override functions 518 # in addition to setting the variables mentioned in the function 519 # DefaultInstanceConfiguration(), this maybe useful to override 520 # functionality used to determine the default deployment environment 521 # find dependencies or validate the configuration, for example. 522 523 if [ -n "${OPENGROK_CONFIGURATION}" -a -f "${OPENGROK_CONFIGURATION}" ] 524 then 525 # Load the Local OpenGrok Configuration Environment 526 Progress "Loading ${OPENGROK_CONFIGURATION} ..." 527 . "${OPENGROK_CONFIGURATION}" 528 else 529 Progress "Loading the default instance configuration ..." 530 DefaultInstanceConfiguration 531 fi 532 } 533 534 ValidateConfiguration() 535 { 536 if [ ! -x "${EXUBERANT_CTAGS}" ] 537 then 538 FatalError "Missing Dependent Application - Exuberant CTags" 539 fi 540 541 if [ ! -d "${SRC_ROOT}" ] 542 then 543 FatalError "OpenGrok Source Path ${SRC_ROOT} doesn't exist" 544 fi 545 546 if [ -n "${QUIET}" -a -n "${VERBOSE}" ] 547 then 548 Warning "Both Quiet and Verbose Mode Enabled - Choosing Verbose" 549 QUIET="" 550 VERBOSE="-v" 551 fi 552 } 553 554 CreateRuntimeRequirements() 555 { 556 if [ ! -d "${DATA_ROOT}" ] 557 then 558 Warning "OpenGrok Generated Data Path ${DATA_ROOT} doesn't exist" 559 Progress " Attempting to create generated data directory ... " 560 ${DO} mkdir -p "${DATA_ROOT}" 561 fi 562 if [ ! -d "${DATA_ROOT}" ] 563 then 564 FatalError "OpenGrok Data Path ${DATA_ROOT} doesn't exist" 565 fi 566 567 if [ ! -d "${OPENGROK_INSTANCE_BASE}/etc" ] 568 then 569 Warning "OpenGrok Generated Etc Path ${OPENGROK_INSTANCE_BASE}/etc doesn't exist" 570 Progress " Attempting to create generated etc directory ... " 571 ${DO} mkdir -p "${OPENGROK_INSTANCE_BASE}/etc" 572 fi 573 if [ ! -d "${OPENGROK_INSTANCE_BASE}/etc" ] 574 then 575 FatalError "OpenGrok Etc Path ${OPENGROK_INSTANCE_BASE}/etc doesn't exist" 576 fi 577 578 if [ -n "${LOGGER_CONFIG_PATH}" -a ! -f "${LOGGER_CONFIG_PATH}" ] 579 then 580 Progress " Creating default ${LOGGER_CONFIG_PATH} ... " 581 if [ ! -f "${LOGGER_CONF_SOURCE}" ] 582 then 583 Warning "Can't find distribution logging configuration" \ 584 "(${LOGGER_CONF_SOURCE}) to install as default" \ 585 "logging configuration (${LOGGER_CONFIG_PATH})" 586 else 587 ${DO} grep -v java.util.logging.FileHandler.pattern "${LOGGER_CONF_SOURCE}" > "${LOGGER_CONFIG_PATH}" 588 ${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}" 589 ${DO} mkdir ${OPENGROK_INSTANCE_BASE}/log 590 fi 591 fi 592 } 593 594 StdInvocation() 595 { 596 ${DO} ${JAVA} ${JAVA_OPTS} ${PROPERTIES} \ 597 ${LOGGER_PROPERTIES} \ 598 ${JAVA_DEBUG} \ 599 -jar ${OPENGROK_JAR} \ 600 ${IGNORE_PATTERNS} ${ENABLE_PROJECTS} \ 601 ${DERBY_HISTORY_CACHE} \ 602 ${SCAN_FOR_REPOSITORY} ${REMOTE_REPOSITORIES} \ 603 ${SCAN_DEPTH} \ 604 ${VERBOSE} ${QUIET} \ 605 ${EXUBERANT_CTAGS:+-c} ${EXUBERANT_CTAGS} \ 606 ${MAX_INDEXED_WORDS} ${SKIN} ${LEADING_WILDCARD} \ 607 ${READ_XML_CONF} \ 608 -W ${XML_CONFIGURATION} \ 609 ${WEBAPP_CONFIG_ADDRESS} \ 610 -s ${SRC_ROOT} -d ${DATA_ROOT} \ 611 "${@}" 612 613 } 614 615 UpdateGeneratedData() 616 { 617 StdInvocation -H 618 } 619 620 UpdateDescriptionCache() 621 { 622 # OPTIONAL : Update the EftarFile data 623 624 if [ -n "${PATH_DESC}" -a -s "${PATH_DESC}" ] 625 then 626 ${DO} ${JAVA} -classpath ${OPENGROK_JAR} \ 627 ${EFTAR_UPDATE} ${PATH_DESC} ${EFTAR_OUTPUT_FILE} 628 fi 629 } 630 631 OpenGrokUsage() 632 { 633 echo "Options for opengrok.jar:" 1>&2 634 ${DO} ${JAVA} ${JAVA_OPTS} -jar ${OPENGROK_JAR} '-?' 635 } 636 637 DeployWar() 638 { 639 applicationServer="`FindApplicationServerType`" 640 641 case "${applicationServer}" in 642 643 Tomcat) warTarget="`DetermineWarDirectoryTomcat`" ;; 644 Glassfish) warTarget="`DetermineWarDirectoryGlassfish`" ;; 645 646 *) FatalError "Unsupported Application Server ${applicationServer}" ;; 647 648 esac 649 650 if [ -z "${warTarget}" ] 651 then 652 FatalError "Unable to determine Deployment Directory for ${applicationServer}" 653 fi 654 655 if [ ! -f "${OPENGROK_DIST_WAR}" ] 656 then 657 FatalError "Missing Web Application Archive ${OPENGROK_DIST_WAR}" 658 fi 659 660 if [ ! -d "${warTarget}" ] 661 then 662 FatalError "Missing Deployment Directory ${warTarget}" 663 fi 664 665 Progress "Installing ${OPENGROK_DIST_WAR} to ${warTarget} ..." 666 ${DO} cp "${OPENGROK_DIST_WAR}" "${warTarget}/" 667 if [ $? != 0 ] 668 then 669 FatalError "Web Application Installation FAILED" 670 fi 671 672 Progress 673 Progress "Start your application server (${applicationServer}), if it is not already" 674 Progress "running, or wait until it loads the just installed web application." 675 Progress 676 Progress "OpenGrok should be available on <HOST>:<PORT>/source" 677 Progress " where HOST and PORT are configured in ${applicationServer}." 678 Progress 679 } 680 681 # 682 # Main Program 683 # 684 685 if [ $# -eq 0 -o $# -gt 2 ] 686 then 687 Usage 688 fi 689 690 LoadStandardEnvironment 691 692 LoadInstanceConfiguration 693 694 case "${1}" in 695 696 deploy) 697 DeployWar 698 ;; 699 700 update) 701 ValidateConfiguration 702 CreateRuntimeRequirements 703 UpdateGeneratedData 704 UpdateDescriptionCache 705 ;; 706 707 updateQuietly) 708 ValidateConfiguration 709 CreateRuntimeRequirements 710 QUIET="-q" 711 VERBOSE="" 712 UpdateGeneratedData 713 UpdateDescriptionCache 714 ;; 715 716 index) 717 if [ -n "${2}" ] 718 then 719 SRC_ROOT="${2}" 720 fi 721 ValidateConfiguration 722 CreateRuntimeRequirements 723 UpdateGeneratedData 724 UpdateDescriptionCache 725 ;; 726 727 usage) 728 OpenGrokUsage 729 Usage 730 ;; 731 732 *) 733 Usage 734 ;; 735 736 esac 737 738 # 739 # End of File 740 # 741