b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger# Supported Environment Variables:
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger# - OPENGROK_STANDARD_ENV Run Time Shell Environment (Shell Script)
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger# - OPENGROK_CONFIGURATION User Configuration (Shell Script)
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger# Supported Environment Variables for configuring the default setup:
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger# - OPENGROK_DISTRIBUTION_BASE Base Directory of the OpenGrok Distribution
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger# - containing the opengrok.jar
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger# - OPENGROK_JAR Directly specify the opengrok.jar file
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger# - OPENGROK_INSTANCE_BASE Base Directory of the OpenGrok User Data Area
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger# - determining the configuration
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger# switch), default is DATA_ROOT/etc/ctags.config
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger# - JAVA_HOME Full Path to Java Installation Root
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger# - JAVA Full Path to java binary (to enable 64bit JDK)
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger# - JAVA_OPTS Java options (e.g. for JVM memory increase view
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger# - READ_XML_CONFIGURATION file with read only configuration
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger# - determining the configuration
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof TulingerSCRIPT_DIRECTORY=`cd "${SCRIPT_DIRECTORY}"; pwd`
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger echo "Usage: ${PROGNAME} <add|delete|match|list|help> [--help] [--verbose] [-d]"
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger echo " The script searches for the configuration in"
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger echo " OPENGROK_INSTANCE_BASE/etc/configuration.xml or"
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger echo " When no such file exists it uses an empty configuration."
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger echo " OPENGROK_CONFIGURATION - location of your configuration"
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger echo " e.g. $ OPENGROK_CONFIGURATION=/var/opengrok/myog.conf ${0} ... "
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger echo " See the code for more information on configuration options /" \
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger ${JAVA_CLASSPATH:+-classpath} ${JAVA_CLASSPATH} \
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger ${INPUT_FILE:+-i} ${INPUT_FILE:+"$INPUT_FILE"} \
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger ${OUTPUT_FILE:+-o} ${OUTPUT_FILE:+"$OUTPUT_FILE"} \
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger if [ -n "$INPUT_FILE" ] && ( [ ! -e "$INPUT_FILE" ] || [ ! -f "$INPUT_FILE" ] )
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger echo "input file does not exist or is not readable"
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger echo "\tJAVA_CLASSPATH = "${JAVA_CLASSPATH}
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger echo "\tOPENGROK_CONFIGURATION = "${OPENGROK_CONFIGURATION}
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger echo "\tOPENGROK_STANDARD_ENV = "${OPENGROK_STANDARD_ENV}
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger echo "\tOPENGROK_INSTANCE_BASE = "${OPENGROK_INSTANCE_BASE}
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger echo "\tOPENGROK_DISTRIBUTION_BASE = "${OPENGROK_DISTRIBUTION_BASE}
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger echo "\tREAD_XML_CONFIGURATION = "${READ_XML_CONFIGURATION}
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger echo "\tINPUT_FILE = "${INPUT_FILE:-empty configuration}
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger echo "\tOUTPUT_FILE = "${OUTPUT_FILE:-standard output}
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger echo "${PROGNAME} match <project name> [-i|--input <file>] [-v|--verbose] [-d]"
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger echo " Lists which groups would match the project name (description)"
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger echo " -d option performs dry run with verbose mode"
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger echo " -i option can be used for specifying the input file"
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger while [ $# -gt 0 ]
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger echo "Uknown option \"$opt\"" && LocalUsage && exit 5
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger echo "match must be specified only once" && LocalUsage && exit 5
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger [ -z "$MATCH" ] && echo "project name must be specified" && LocalUsage && exit 5
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger echo "${PROGNAME} list [-i|--input <file>] [-v|--verbose] [-d]"
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger echo " -d option performs dry run with verbose mode"
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger echo " -i option can be used for specifying the input file"
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger while [ $# -gt 0 ]
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger echo "Uknown option \"$opt\"" && LocalUsage && exit 5
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger echo "${PROGNAME} delete <name> [-i|--input <file>] [-o|--output <file>] [-l] [-v|--verbose] [-u|--update] [-d]"
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger echo " Deletes a group with given name from the input configuration"
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger echo " -d option performs dry run with verbose mode"
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger echo " -i option can be used for specifying the input file"
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger echo " -l option prints the overview to stdout (still -o can be used)"
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger echo " -o option can be used for saving the result"
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger echo " -u option forces the script to use same output file as input file (overwrite)"
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger while [ $# -gt 0 ]
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger echo "Uknown option \"$opt\"" && LocalUsage && exit 5
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger echo "name must be specified only once" && LocalUsage && exit 5
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger [ -z "$NAME" ] && echo "name must be specified" && LocalUsage && exit 5
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger echo "${PROGNAME} add <name> <pattern> [-i|--input <file>] [-o|--output <file>] [-l] [-v|--verbose] [-u|--update] [-d]"
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger echo " Adds or updates a group with given name"
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger echo " 1) If given group name already exists, the pattern is updated."
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger echo " 2) If given group name does not exist, the group is inserted"
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger echo " 3) If the parent group exists, the group is inserted as its child"
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger echo " -d option performs dry run with verbose mode"
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger echo " -i option can be used for specifying the input file"
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger echo " -l option prints the overview to stdout (still -o can be used)"
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger echo " -o option can be used for saving the result"
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger echo " -u option forces the script to use same output file as input file (overwrite)"
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger while [ $# -gt 0 ]
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger echo "Uknown option \"$opt\"" && LocalUsage && exit 5
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger echo "name and pattern must be specified only once" && LocalUsage && exit 5
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger [ -z "$NAME" ] && echo "name must be specified" && LocalUsage && exit 5
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger [ -z "$PATTERN" ] && echo "pattern must be specified" && LocalUsage && exit 5
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger# Find and load relevant configuration
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger# Taken (and modified) from original OpenGrok shell wrapper
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger OPENGROK_INSTANCE_BASE="${OPENGROK_INSTANCE_BASE:-/var/opengrok}"
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger Progress "Loading ${OPENGROK_STANDARD_ENV} ..."
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger if [ -n "${OPENGROK_CONFIGURATION}" -a -f "${OPENGROK_CONFIGURATION}" ]
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger # Load the Local OpenGrok Configuration Environment
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger Progress "Loading ${OPENGROK_CONFIGURATION} ..."
3d4f2c2ca2b88224b3808aa18937a3872d3f3aa8Kryštof Tulinger -f "${SCRIPT_DIRECTORY}/../dist/opengrok.jar" -a \
3d4f2c2ca2b88224b3808aa18937a3872d3f3aa8Kryštof Tulinger -f "${SCRIPT_DIRECTORY}/../dist/source.war" \
3d4f2c2ca2b88224b3808aa18937a3872d3f3aa8Kryštof Tulinger OPENGROK_DISTRIBUTION_BASE="${SCRIPT_DIRECTORY}/../dist"
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger OPENGROK_DISTRIBUTION_BASE="${SCRIPT_DIRECTORY}/../lib"
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger # REQUIRED: Java Archive of OpenGrok (Installation Location)
3d4f2c2ca2b88224b3808aa18937a3872d3f3aa8Kryštof Tulinger OPENGROK_JAR="${OPENGROK_JAR:-${OPENGROK_DISTRIBUTION_BASE}/opengrok.jar}"
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger JAVA_CLASSPATH="${JAVA_CLASSPATH}:${OPENGROK_JAR}"
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger MAIN_CLASS="org.opensolaris.opengrok.configuration.Groups"
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger if [ -n "$OPENGROK_INSTANCE_BASE" ] && [ -f "$OPENGROK_INSTANCE_BASE/etc/configuration.xml" ]
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger INPUT_FILE="$OPENGROK_INSTANCE_BASE/etc/configuration.xml"
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger elif [ -n "$READ_XML_CONFIGURATION" ] && [ -f "$READ_XML_CONFIGURATION" ]
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger# Find java home based on your system information
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger# Taken from original OpenGrok shell wrapper
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger echo "Cannot determine operating system version"
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger SunOS:5.10) javaHome="/usr/jdk/instances/jdk1.7.0" ;;
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger Darwin:*) javaHome=`/usr/libexec/java_home` ;;
37f9c1e7d36aad830845ddc6a1bb3c978e5a5bd1Kryštof Tulinger javaHome=`ls -l /etc/alternatives/java | cut -f 2 -d \> `