Groups revision b4b45a7526fef6a514d6c746d80a05f898ba573d
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
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger# - determining the opengrok.jar
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger# - OPENGROK_INSTANCE_BASE Base Directory of the OpenGrok User Data Area
b4b45a7526fef6a514d6c746d80a05f898ba573dKryš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
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger# - determining the configuration
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 /" \
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger ${JAVA_CLASSPATH:+-classpath} ${JAVA_CLASSPATH} \
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger ${INPUT_FILE:+-i} ${INPUT_FILE:+"$INPUT_FILE"} \
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger ${OUTPUT_FILE:+-o} ${OUTPUT_FILE:+"$OUTPUT_FILE"} \
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger if [ -n "$INPUT_FILE" ] && ( [ ! -e "$INPUT_FILE" ] || [ ! -f "$INPUT_FILE" ] )
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger echo "input file does not exist or is not readable"
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger echo "\tJAVA_CLASSPATH = "${JAVA_CLASSPATH}
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger echo "\tOPENGROK_CONFIGURATION = "${OPENGROK_CONFIGURATION}
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger echo "\tOPENGROK_STANDARD_ENV = "${OPENGROK_STANDARD_ENV}
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger echo "\tOPENGROK_INSTANCE_BASE = "${OPENGROK_INSTANCE_BASE}
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger echo "\tOPENGROK_DISTRIBUTION_BASE = "${OPENGROK_DISTRIBUTION_BASE}
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger echo "\tREAD_XML_CONFIGURATION = "${READ_XML_CONFIGURATION}
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger echo "\tINPUT_FILE = "${INPUT_FILE:-empty configuration}
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger echo "\tOUTPUT_FILE = "${OUTPUT_FILE:-standard output}
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger echo "${PROGNAME} match <project name> [-i|--input <file>] [-v|--verbose] [-d]"
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger echo " Lists which groups would match the project name (description)"
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger echo " -d option performs dry run with verbose mode"
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger echo " -i option can be used for specifying the input file"
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger while [ $# -gt 0 ]
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger echo "Uknown option \"$opt\"" && LocalUsage && exit 5
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger echo "match must be specified only once" && LocalUsage && exit 5
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger [ -z "$MATCH" ] && echo "project name must be specified" && LocalUsage && exit 5
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger echo "${PROGNAME} list [-i|--input <file>] [-v|--verbose] [-d]"
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger echo " -d option performs dry run with verbose mode"
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger echo " -i option can be used for specifying the input file"
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger while [ $# -gt 0 ]
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger echo "Uknown option \"$opt\"" && LocalUsage && exit 5
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger echo "${PROGNAME} delete <name> [-i|--input <file>] [-o|--output <file>] [-l] [-v|--verbose] [-u|--update] [-d]"
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger echo " Deletes a group with given name from the input configuration"
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger echo " -d option performs dry run with verbose mode"
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger echo " -i option can be used for specifying the input file"
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger echo " -l option prints the overview to stdout (still -o can be used)"
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger echo " -o option can be used for saving the result"
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger echo " -u option forces the script to use same output file as input file (overwrite)"
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger while [ $# -gt 0 ]
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger echo "Uknown option \"$opt\"" && LocalUsage && exit 5
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger echo "name must be specified only once" && LocalUsage && exit 5
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger [ -z "$NAME" ] && echo "name must be specified" && LocalUsage && exit 5
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger echo "${PROGNAME} add <name> <pattern> [-i|--input <file>] [-o|--output <file>] [-l] [-v|--verbose] [-u|--update] [-d]"
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger echo " Adds or updates a group with given name"
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger echo " 1) If given group name already exists, the pattern is updated."
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger echo " 2) If given group name does not exist, the group is inserted"
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger echo " 3) If the parent group exists, the group is inserted as its child"
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger echo " -d option performs dry run with verbose mode"
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger echo " -i option can be used for specifying the input file"
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger echo " -l option prints the overview to stdout (still -o can be used)"
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger echo " -o option can be used for saving the result"
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger echo " -u option forces the script to use same output file as input file (overwrite)"
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger while [ $# -gt 0 ]
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger echo "Uknown option \"$opt\"" && LocalUsage && exit 5
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger echo "name and pattern must be specified only once" && LocalUsage && exit 5
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger [ -z "$NAME" ] && echo "name must be specified" && LocalUsage && exit 5
b4b45a7526fef6a514d6c746d80a05f898ba573dKryš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
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} ..."
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger if [ -n "$OPENGROK_DISTRIBUTION_BASE" ] && [ -f "$OPENGROK_DISTRIBUTION_BASE/dist/opengrok.jar" ]
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger OPENGROK_JAR="$OPENGROK_DISTRIBUTION_BASE/dist/opengrok.jar"
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger if [ -z "$OPENGROK_JAR" ] && [ -f "../dist/opengrok.jar" ]
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger OPENGROK_JAR="${OPENGROK_JAR:-../dist/opengrok.jar}"
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger elif [ -z "$OPENGROK_JAR" ] && [ -f "dist/opengrok.jar" ]
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger OPENGROK_JAR="${OPENGROK_JAR:-dist/opengrok.jar}"
b4b45a7526fef6a514d6c746d80a05f898ba573dKryš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" ]
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger INPUT_FILE="$OPENGROK_INSTANCE_BASE/etc/configuration.xml"
b4b45a7526fef6a514d6c746d80a05f898ba573dKryš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
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger echo "Cannot determine operating system version"
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger SunOS:5.10) javaHome="/usr/jdk/instances/jdk1.7.0" ;;
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger Darwin:*) javaHome=`/usr/libexec/java_home` ;;
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger javaHome=`ls -l /etc/alternatives/java | cut -f 2 -d \> `