Messages revision 838924562130977ca1a3d3839d146fcda39ea1af
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger#!/bin/ksh
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger# Supported Environment Variables:
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger# - OPENGROK_STANDARD_ENV Run Time Shell Environment (Shell Script)
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger# - OPENGROK_CONFIGURATION User Configuration (Shell Script)
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger#
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger# Supported Environment Variables for configuring the default setup:
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger# - OPENGROK_DISTRIBUTION_BASE Base Directory of the OpenGrok Distribution
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger# - containing the opengrok.jar
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger# - OPENGROK_JAR OpenGrok java package
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger# switch), default is DATA_ROOT/etc/ctags.config
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger# - JAVA_HOME Full Path to Java Installation Root
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger# - JAVA Full Path to java binary (to enable 64bit JDK)
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger# - JAVA_OPTS Java options (e.g. for JVM memory increase view
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger
838924562130977ca1a3d3839d146fcda39ea1afKryštof TulingerPROGNAME=`basename $0`
838924562130977ca1a3d3839d146fcda39ea1afKryštof TulingerDATE="${DATE:-date}"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger
838924562130977ca1a3d3839d146fcda39ea1afKryštof TulingerSCRIPT_DIRECTORY=`dirname "${0}"`
838924562130977ca1a3d3839d146fcda39ea1afKryštof TulingerSCRIPT_DIRECTORY=`cd "${SCRIPT_DIRECTORY}"; pwd`
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger
838924562130977ca1a3d3839d146fcda39ea1afKryštof TulingerUsage()
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger{
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger exec >&2
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo ""
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo "Usage: ${PROGNAME} [options] <text>"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo ""
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo "[OPTIONS]:"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo " -e|--expire human readable date string of expiration (default +5 min) (*)"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo " --expire-timestamp explicit UTC timestamp for expiration in sec"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo " -c|--class css class to apply for the message (default info)"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo " -p|--port remote port number of the application (default 2424)"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo " -s|--server remote server of the application (default localhost)"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo " -t|--tag tag the message/multiple options (default main)"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo " --type type of the message (default normal)"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo " -v verbose"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo ""
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo " (*) see man date: option --date"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo " css classes: success, info, warning, error"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo " types: normal, abort"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo " tags: main, $projectDescription"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo " text: supports html markup"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo ""
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo " Optional environment variables:"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo " OPENGROK_CONFIGURATION - location of your configuration"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo " e.g. $ OPENGROK_CONFIGURATION=/var/opengrok/myog.conf ${0} ... "
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo ""
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo " See the code for more information on configuration options /" \
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger "variables"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo ""
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger}
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger
838924562130977ca1a3d3839d146fcda39ea1afKryštof TulingerCommonInvocation()
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger{
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger ${DO} \
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger ${JAVA} \
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger ${JAVA_OPTS} \
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger ${JAVA_CLASSPATH:+-classpath} ${JAVA_CLASSPATH} \
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger ${MAIN_CLASS} \
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger "${@}"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger}
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger
838924562130977ca1a3d3839d146fcda39ea1afKryštof TulingerStdInvocation()
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger{
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger CommonInvocation \
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger ${MESSAGE_TYPE:+-m} ${MESSAGE_TYPE:+"$MESSAGE_TYPE"} \
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger ${MESSAGE_CLASS:+-c} ${MESSAGE_CLASS:+"$MESSAGE_CLASS"} \
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger ${MESSAGE_TAGS:+"${MESSAGE_TAGS[@]}"} \
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger ${MESSAGE_EXPIRE_TIMESTAMP:+-e} ${MESSAGE_EXPIRE_TIMESTAMP:+"$MESSAGE_EXPIRE_TIMESTAMP"} \
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger ${REMOTE_SERVER:+-s} ${REMOTE_SERVER:+"$REMOTE_SERVER"} \
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger ${REMOTE_PORT_NUM:+-p} ${REMOTE_PORT_NUM:+"$REMOTE_PORT_NUM"} \
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger ${MESSAGE_TEXT:+-t} ${MESSAGE_TEXT:+"$MESSAGE_TEXT"} \
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger "${@}"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger}
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger
838924562130977ca1a3d3839d146fcda39ea1afKryštof TulingerOneArgument()
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger{
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger if [ $# -gt 0 ]
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger then
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo "$1"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger fi
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger}
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger
838924562130977ca1a3d3839d146fcda39ea1afKryštof TulingerExpectOption()
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger{
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger if [ $# -lt 2 ]
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger then
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo "Argument \"$1\" expects a value"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger exit 3
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger fi
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger}
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger
838924562130977ca1a3d3839d146fcda39ea1afKryštof TulingerInfo()
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger{
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger if $VERBOSE
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger then
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo "Configuration loaded"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo -e "\tJAVA_HOME = "${JAVA_HOME}
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger if [ -n "$JAVA_HOME" ]
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger then
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo -e "\tJAVA = $JAVA_HOME/bin/java"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger else
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo -e "\tJAVA ="
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger fi
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo -e "\tJAVA_OPTS = "${JAVA_OPTS}
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo -e "\tJAVA_CLASSPATH = "${JAVA_CLASSPATH}
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo -e "\tOPENGROK_JAR = "${OPENGROK_JAR}
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo -e "\tOPENGROK_CONFIGURATION = "${OPENGROK_CONFIGURATION}
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo -e "\tOPENGROK_STANDARD_ENV = "${OPENGROK_STANDARD_ENV}
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo -e "\tOPENGROK_DISTRIBUTION_BASE = "${OPENGROK_DISTRIBUTION_BASE}
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo -e "\tOPENGROK_JAR = "${OPENGROK_JAR}
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo ""
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo "Files used"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo -e "\tDATE = "${DATE:-$DATE}
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo -e "\tREMOTE_SERVER = "${REMOTE_SERVER:-$REMOTE_SERVER}
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo -e "\tREMOTE_PORT_NUM = "${REMOTE_PORT_NUM:-$REMOTE_PORT_NUM}
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo -e "\tMESSAGE_TYPE = "${MESSAGE_TYPE:-$MESSAGE_TYPE}
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo -e "\tMESSAGE_TAGS = "${MESSAGE_TAGS[*]:-${MESSAGE_TAGS[*]}}
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo -e "\tMESSAGE_CLASS = "${MESSAGE_CLASS:-$MESSAGE_CLASS}
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo -e "\tMESSAGE_EXPIRE = "${MESSAGE_EXPIRE:-$MESSAGE_EXPIRE}
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo -e "\tMESSAGE_EXPIRE_TIMESTAMP = "${MESSAGE_EXPIRE_TIMESTAMP:-$MESSAGE_EXPIRE_TIMESTAMP}
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo -e "\tMESSAGE_TEXT = "${MESSAGE_TEXT:-$MESSAGE_TEXT}
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo ""
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger fi
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger}
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger
838924562130977ca1a3d3839d146fcda39ea1afKryštof TulingerProgress()
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger{
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger if $VERBOSE
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger then
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo "$@"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger fi
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger}
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger# Find and load relevant configuration
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger#
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger# Taken (and modified) from original OpenGrok shell wrapper
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger#
838924562130977ca1a3d3839d146fcda39ea1afKryštof TulingerSetupInstanceConfiguration()
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger{
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger VERBOSE="${VERBOSE:-false}"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger if [ -f "${OPENGROK_STANDARD_ENV}" ]
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger then
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger Progress "Loading ${OPENGROK_STANDARD_ENV} ..."
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger . "${OPENGROK_STANDARD_ENV}"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger fi
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger if [ -n "${OPENGROK_CONFIGURATION}" -a -f "${OPENGROK_CONFIGURATION}" ]
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger then
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger # Load the Local OpenGrok Configuration Environment
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger Progress "Loading ${OPENGROK_CONFIGURATION} ..."
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger . "${OPENGROK_CONFIGURATION}"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger fi
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger if [ -z "${OPENGROK_DISTRIBUTION_BASE}" ]
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger then
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger if [ -d "${SCRIPT_DIRECTORY}/../dist" -a \
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger -f "${SCRIPT_DIRECTORY}/../dist/opengrok.jar" -a \
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger -f "${SCRIPT_DIRECTORY}/../dist/source.war" \
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger ]
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger then
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger # Handle Developer Build Environments
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger OPENGROK_DISTRIBUTION_BASE="${SCRIPT_DIRECTORY}/../dist"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger else
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger # Handle Binary Distributions
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger OPENGROK_DISTRIBUTION_BASE="${SCRIPT_DIRECTORY}/../lib"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger fi
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger fi
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger # REQUIRED: Java Home
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger JAVA_HOME="${JAVA_HOME:-`FindJavaHome`}"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger # REQUIRED: Java Virtual Machine
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger JAVA="${JAVA:-$JAVA_HOME/bin/java}"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger # REQUIRED: OpenGrok library
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger OPENGROK_JAR="${OPENGROK_JAR:-${OPENGROK_DISTRIBUTION_BASE}/opengrok.jar}"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger JAVA_CLASSPATH="$CLASSPATH"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger JAVA_CLASSPATH="${JAVA_CLASSPATH}:${OPENGROK_JAR}"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger JAVA_OPTS="${JAVA_OPTS:--Xmx2048m}"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger MAIN_CLASS="org.opensolaris.opengrok.configuration.messages.Messages"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger REMOTE_SERVER="localhost"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger REMOTE_PORT_NUM=2424
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger MESSAGE_TYPE="normal"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger typeset -a MESSAGE_TAGS
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger MESSAGE_CLASS="info"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger MESSAGE_EXPIRE="+5 min"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger unset MESSAGE_TEXT
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger VERBOSE=false
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger}
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger# Find java home based on your system information
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger#
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger# Taken from original OpenGrok shell wrapper
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger#
838924562130977ca1a3d3839d146fcda39ea1afKryštof TulingerFindJavaHome()
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger{
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger if [ -x "/bin/uname" ]; then
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger OS_NAME="`/bin/uname -s`"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger OS_VERSION="`/bin/uname -r`"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger elif [ -x "/usr/bin/uname" ]; then
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger OS_NAME="`/usr/bin/uname -s`"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger OS_VERSION="`/usr/bin/uname -r`"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger else
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo "Cannot determine operating system version"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger exit 3
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger fi
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger javaHome=""
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger case "${OS_NAME}:${OS_VERSION}" in
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger SunOS:5.10) javaHome="/usr/jdk/instances/jdk1.7.0" ;;
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger SunOS:5.11) javaHome="/usr/jdk/latest" ;;
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger SunOS:5.12) javaHome="/usr/jdk/latest" ;;
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger Darwin:*) javaHome=`/usr/libexec/java_home` ;;
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger Linux:*)
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger if [ -f /etc/alternatives/java ]
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger then
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger javaHome=`ls -l /etc/alternatives/java | cut -f 2 -d \> `
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger javaHome=`dirname $javaHome`
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger javaHome=`dirname $javaHome`
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger fi
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger ;;
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger esac
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger if [ -z "${javaHome}" ]
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger then
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo "Unable to determine Java Home" \
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger "for ${OS_NAME} ${OS_VERSION}"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger exit 3
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger fi
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger if [ ! -d "${javaHome}" ]
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger then
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo "Missing Java Home ${javaHome}"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger exit 3
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger fi
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo "${javaHome}"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger}
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulingerif [ $# -eq 0 ]
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulingerthen
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo "Bad syntax. Expecting some arguments."
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo "Maybe try --help option?"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger exit 3
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulingerfi
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger
838924562130977ca1a3d3839d146fcda39ea1afKryštof TulingerSetupInstanceConfiguration
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulingerwhile [ $# -gt 0 ]
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulingerdo
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger opt="$1"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger case $opt in
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger -s|--server)
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger ExpectOption "$@"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger shift
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger REMOTE_SERVER=$(OneArgument "$@")
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger ;;
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger -p|--port)
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger ExpectOption "$@"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger shift
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger REMOTE_PORT_NUM=$(OneArgument "$@")
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger ;;
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger --type)
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger ExpectOption "$@"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger shift
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger MESSAGE_TYPE=$(OneArgument "$@")
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger ;;
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger -t|--tag)
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger ExpectOption "$@"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger shift
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger MESSAGE_TAGS+=(-g "$(OneArgument "$@")")
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger ;;
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger -c|--class)
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger ExpectOption "$@"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger shift
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger MESSAGE_CLASS=$(OneArgument "$@")
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger ;;
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger -e|--expire)
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger ExpectOption "$@"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger shift
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger MESSAGE_EXPIRE=$(OneArgument "$@")
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger ;;
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger --expire-timestamp)
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger ExpectOption "$@"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger shift
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger MESSAGE_EXPIRE_TIMESTAMP=$(OneArgument "$@")
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger ;;
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger -v|--verbose)
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger VERBOSE=true
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger ;;
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger -h|--help)
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger Usage
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger exit 0
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger ;;
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger -*)
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo "Uknown option \"$opt\"" && Usage && exit 5
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger ;;
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger *)
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger if [ $# -ne 1 ]
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger then
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo "Bad syntax. The text should be the last argument."
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo "Stopped near \"$@\"."
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo "Check the quotes around the arguments?"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger exit 3
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger fi
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger if [ "x$MESSAGE_TEXT" = "x" ]
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger then
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger MESSAGE_TEXT="$@"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger break # exit the while cycle
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger else
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo "Bad syntax. The text must be specified only once."
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger exit 3
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger fi
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger ;;
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger esac
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger shift
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulingerdone
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger[ -z "$MESSAGE_TEXT" ] && echo "The text of the message must be specified" && Usage && exit 3
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger[ -z "$MESSAGE_EXPIRE" ] && echo "The expire must be set" && Usage && exit 5
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulingerif [ -z "$MESSAGE_EXPIRE_TIMESTAMP" ]
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulingerthen
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger MESSAGE_EXPIRE_TIMESTAMP=`"$DATE" --date="$MESSAGE_EXPIRE" +"%s"`
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger if [ $? -ne 0 ]
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger then
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo "The date couldn't parse the input '$MESSAGE_EXPIRE'."
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo "Consider installing gnu date and setting env variable DATE."
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger exit 5;
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger fi
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulingerfi
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger[ -z "${MESSAGE_TAGS[*]}" ] && MESSAGE_TAGS=(-g 'main')
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger
838924562130977ca1a3d3839d146fcda39ea1afKryštof TulingerInfo
838924562130977ca1a3d3839d146fcda39ea1afKryštof TulingerStdInvocation