# 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 lib/opengrok.jar
# - OPENGROK_JAR OpenGrok java package
# - DATE GNU date binary (supporting --date switch)
# - 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
then
DATE="${DATE:-date}"
else
DATE="${DATE:-gdate}"
fi
{
exec >&2
echo ""
echo "Usage: ${PROGNAME} [options] <text>"
echo ""
echo "[OPTIONS]:"
echo " -c|--class css class to apply for the message (default info)"
echo " -e|--expire human readable date string of expiration (default +5 min) (*)"
echo " -h|--help display this message and exit"
echo " -n|--type type of the message (default normal)"
echo " -p|--port remote port number of the application (default 2424)"
echo " -s|--server remote server of the application (default localhost)"
echo " -u|--expire-timestamp explicit UTC timestamp for expiration in sec"
echo " -v|--verbose verbose"
echo ""
echo " (*) see man date: option --date (requires GNU date - use DATE env variable)"
echo " css classes: success, info, warning, error"
echo " types: normal, abort"
echo " tags: main, <project name>"
echo " text: supports html markup"
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} \
"${@}"
}
{
"${@}"
}
{
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 -e "\tJAVA = $JAVA_HOME/bin/java"
else
echo -e "\tJAVA ="
fi
echo ""
echo "Files used"
echo ""
fi
}
{
if $VERBOSE
then
echo "$@"
fi
}
# Find and load relevant configuration
#
# Taken (and modified) from original OpenGrok shell wrapper
#
{
VERBOSE="${VERBOSE:-false}"
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
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 Home
# REQUIRED: Java Virtual Machine
JAVA="${JAVA:-$JAVA_HOME/bin/java}"
# REQUIRED: OpenGrok library
OPENGROK_JAR="${OPENGROK_JAR:-${OPENGROK_DISTRIBUTION_BASE}/opengrok.jar}"
JAVA_CLASSPATH="${JAVA_CLASSPATH}:${OPENGROK_JAR}"
JAVA_OPTS="${JAVA_OPTS:--Xmx2048m}"
REMOTE_SERVER="localhost"
REMOTE_PORT_NUM=2424
MESSAGE_TYPE="normal"
typeset -a MESSAGE_TAGS
MESSAGE_CLASS="info"
MESSAGE_EXPIRE="+5 min"
unset MESSAGE_TEXT
VERBOSE=false
}
# 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
echo "Bad syntax. Expecting some arguments."
echo "Maybe try --help option?"
exit 3
fi
while [ $# -gt 0 ]
do
opt="$1"
-c|--class)
ExpectOption "$@"
shift
;;
-e|--expire)
ExpectOption "$@"
shift
;;
-h|--help)
exit 0
;;
-n|--type)
ExpectOption "$@"
shift
;;
-p|--port)
ExpectOption "$@"
shift
;;
-s|--server)
ExpectOption "$@"
shift
;;
-t|--tag)
ExpectOption "$@"
shift
;;
ExpectOption "$@"
shift
;;
-v|--verbose)
VERBOSE=true
;;
-*)
;;
*)
if [ $# -ne 1 ]
then
echo "Bad syntax. The text should be the last argument."
echo "Stopped near \"$@\"."
echo "Check the quotes around the arguments?"
exit 3
fi
if [ "x$MESSAGE_TEXT" = "x" ]
then
MESSAGE_TEXT="$@"
break # exit the while cycle
else
echo "Bad syntax. The text must be specified only once."
exit 3
fi
;;
esac
shift
done
if [ -z "$MESSAGE_EXPIRE_TIMESTAMP" ]
then
if [ $? -ne 0 ]
then
echo "The date couldn't parse the input '$MESSAGE_EXPIRE'."
echo "Consider installing gnu date and setting env variable DATE."
exit 5;
fi
fi