# Supported Environment Variables:
# - OPENGROK_STANDARD_ENV Run Time Shell Environment (Shell Script)
# - OPENGROK_CONFIGURATION User Configuration (Shell Script)
#
# Supported Environment Variables for configuring the default setup:
# - OPENGROK_DISTRIBUTION_BASE Base Directory of the OpenGrok Distribution
# - containing the opengrok.jar
# - OPENGROK_JAR Directly specify the opengrok.jar file
# - OPENGROK_INSTANCE_BASE Base Directory of the OpenGrok User Data Area
# - determining the configuration
# switch), default is DATA_ROOT/etc/ctags.config
# - JAVA_HOME Full Path to Java Installation Root
# - JAVA Full Path to java binary (to enable 64bit JDK)
# - JAVA_OPTS Java options (e.g. for JVM memory increase view
# - READ_XML_CONFIGURATION file with read only configuration
# - determining the configuration
{
exec >&2
echo ""
echo "Usage: ${PROGNAME} <add|delete|match|list|help> [--help] [--verbose] [-d]"
echo " ${PROGNAME} add <name> <pattern>"
echo " ${PROGNAME} delete <name>"
echo " ${PROGNAME} match <project name>"
echo ""
echo " The script searches for the configuration in"
echo " OPENGROK_INSTANCE_BASE/etc/configuration.xml or"
echo " READ_XML_CONFIGURATION files or"
echo " you can use the -i option."
echo " When no such file exists it uses an empty configuration."
echo ""
echo " Optional environment variables:"
echo " OPENGROK_CONFIGURATION - location of your configuration"
echo ""
echo " See the code for more information on configuration options /" \
"variables"
echo ""
}
{
${DO} \
${JAVA} \
${JAVA_OPTS} \
${JAVA_CLASSPATH:+-classpath} ${JAVA_CLASSPATH} \
${MAIN_CLASS} \
"${@}"
}
{
${LIST:+-l} \
${DELETE:+-d} \
"${@}"
}
{
then
echo "input file does not exist or is not readable"
exit 5
fi
}
{
if [ $# -gt 0 ]
then
echo "$1"
fi
}
{
if [ $# -lt 2 ]
then
echo "Argument \"$1\" expects a value"
exit 3
fi
}
{
if $VERBOSE
then
echo "Configuration loaded"
then
echo "\tJAVA = $JAVA_HOME/bin/java"
else
echo "\tJAVA ="
fi
echo ""
echo "Files used"
echo ""
fi
}
{
if $VERBOSE
then
echo "$@"
fi
}
{
{
echo "Usage:"
echo "${PROGNAME} match <project name> [-i|--input <file>] [-v|--verbose] [-d]"
echo ""
echo " Lists which groups would match the project name (description)"
echo ""
echo "Options:"
echo " -d option performs dry run with verbose mode"
echo " -i option can be used for specifying the input file"
}
while [ $# -gt 0 ]
do
opt="$1"
-i|--input)
ExpectOption "$@"
shift
;;
-d)
DO=echo
VERBOSE=true
;;
-v|--verbose)
VERBOSE=true
;;
-h|--help)
exit 0
;;
-*)
;;
*)
then
else
fi
;;
esac
shift
done
}
{
{
echo "Usage:"
echo "${PROGNAME} list [-i|--input <file>] [-v|--verbose] [-d]"
echo ""
echo " Lists the current configuration"
echo ""
echo "Options:"
echo " -d option performs dry run with verbose mode"
echo " -i option can be used for specifying the input file"
}
while [ $# -gt 0 ]
do
opt="$1"
-i|--input)
ExpectOption "$@"
shift
;;
-d)
DO=echo
VERBOSE=true
;;
-v|--verbose)
VERBOSE=true
;;
-h|--help)
exit 0
;;
-*)
;;
*)
echo "this requires no other parameter"
exit 5
;;
esac
shift
done
LIST=true
}
{
{
echo "Usage:"
echo "${PROGNAME} delete <name> [-i|--input <file>] [-o|--output <file>] [-l] [-v|--verbose] [-u|--update] [-d]"
echo ""
echo " Deletes a group with given name from the input configuration"
echo ""
echo "Options:"
echo " -d option performs dry run with verbose mode"
echo " -i option can be used for specifying the input file"
echo " -l option prints the overview to stdout (still -o can be used)"
echo " -o option can be used for saving the result"
echo " -u option forces the script to use same output file as input file (overwrite)"
}
while [ $# -gt 0 ]
do
opt="$1"
-i|--input)
ExpectOption "$@"
shift
;;
-o|--output)
ExpectOption "$@"
shift
;;
-u|--update)
;;
-l|--list)
LIST=true
;;
-d)
DO=echo
VERBOSE=true
;;
-v|--verbose)
VERBOSE=true
;;
-h|--help)
exit 0
;;
-*)
;;
*)
then
else
fi
;;
esac
shift
done
DELETE=true
}
{
{
echo "Usage:"
echo "${PROGNAME} add <name> <pattern> [-i|--input <file>] [-o|--output <file>] [-l] [-v|--verbose] [-u|--update] [-d]"
echo ""
echo " Adds or updates a group with given name"
echo " 1) If given group name already exists, the pattern is updated."
echo " 2) If given group name does not exist, the group is inserted"
echo " 3) If the parent group exists, the group is inserted as its child"
echo ""
echo "Options:"
echo " -d option performs dry run with verbose mode"
echo " -i option can be used for specifying the input file"
echo " -l option prints the overview to stdout (still -o can be used)"
echo " -o option can be used for saving the result"
echo " -u option forces the script to use same output file as input file (overwrite)"
}
NAME=""
PATTERN=""
while [ $# -gt 0 ]
do
opt="$1"
-i|--input)
ExpectOption "$@"
shift
;;
-o|--output)
ExpectOption "$@"
shift
;;
-p|--parent)
ExpectOption "$@"
shift
;;
-u|--update)
;;
-l|--list)
LIST=true
;;
-d)
DO=echo
VERBOSE=true
;;
-v|--verbose)
VERBOSE=true
;;
-h|--help)
exit 0
;;
-*)
;;
*)
then
then
else
fi
;;
esac
shift
done
}
# Find and load relevant configuration
#
# Taken (and modified) from original OpenGrok shell wrapper
#
{
VERBOSE="${VERBOSE:-false}"
OPENGROK_INSTANCE_BASE="${OPENGROK_INSTANCE_BASE:-/var/opengrok}"
if [ -f "${OPENGROK_STANDARD_ENV}" ]
then
Progress "Loading ${OPENGROK_STANDARD_ENV} ..."
. "${OPENGROK_STANDARD_ENV}"
fi
if [ -n "${OPENGROK_CONFIGURATION}" -a -f "${OPENGROK_CONFIGURATION}" ]
then
# Load the Local OpenGrok Configuration Environment
Progress "Loading ${OPENGROK_CONFIGURATION} ..."
. "${OPENGROK_CONFIGURATION}"
fi
# REQUIRED: Java Home
# REQUIRED: Java Virtual Machine
JAVA="${JAVA:-$JAVA_HOME/bin/java}"
if [ -z "${OPENGROK_DISTRIBUTION_BASE}" ]
then
if [ -d "${SCRIPT_DIRECTORY}/../dist" -a \
]
then
# Handle Developer Build Environments
OPENGROK_DISTRIBUTION_BASE="${SCRIPT_DIRECTORY}/../dist"
else
# Handle Binary Distributions
OPENGROK_DISTRIBUTION_BASE="${SCRIPT_DIRECTORY}/../lib"
fi
fi
# REQUIRED: Java Archive of OpenGrok (Installation Location)
OPENGROK_JAR="${OPENGROK_JAR:-${OPENGROK_DISTRIBUTION_BASE}/opengrok.jar}"
JAVA_CLASSPATH="${JAVA_CLASSPATH}:${OPENGROK_JAR}"
JAVA_OPTS="${JAVA_OPTS:--Xmx2048m}"
unset NAME
unset PATTERN
unset PARENT
unset DELETE
unset MATCH
unset LIST
then
then
fi
}
# Find java home based on your system information
#
# Taken from original OpenGrok shell wrapper
#
{
else
echo "Cannot determine operating system version"
exit 3
fi
javaHome=""
Linux:*)
if [ -f /etc/alternatives/java ]
then
fi
;;
esac
if [ -z "${javaHome}" ]
then
echo "Unable to determine Java Home" \
"for ${OS_NAME} ${OS_VERSION}"
exit 3
fi
if [ ! -d "${javaHome}" ]
then
echo "Missing Java Home ${javaHome}"
exit 3
fi
echo "${javaHome}"
}
if [ $# -eq 0 ]
then
exit 1
fi
case "${1}" in
shift
Match "$@"
;;
shift
Delete "$@"
;;
add)
shift
Add "$@"
;;
list)
shift
List "$@"
;;
help)
exit 0
;;
*)
exit 5
;;
esac