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# Supported Environment Variables for configuring the default setup:
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger# - OPENGROK_DISTRIBUTION_BASE Base Directory of the OpenGrok Distribution
c17bbcd502afbae7853d791a028cd863b736f469Kryštof Tulinger# - containing the lib/opengrok.jar
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger# - OPENGROK_JAR OpenGrok java package
c17bbcd502afbae7853d791a028cd863b736f469Kryštof Tulinger# - DATE GNU date binary (supporting --date switch)
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
c17bbcd502afbae7853d791a028cd863b736f469Kryštof Tulingerif date --date="+5 min" +"%s" >/dev/null 2>&1
838924562130977ca1a3d3839d146fcda39ea1afKryštof TulingerSCRIPT_DIRECTORY=`cd "${SCRIPT_DIRECTORY}"; pwd`
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo " -c|--class css class to apply for the message (default info)"
4ff40998447db64e675e85cda2bf3ae286b71529Kryštof Tulinger echo " -e|--expire human readable date string of expiration (default +5 min) (*)"
4ff40998447db64e675e85cda2bf3ae286b71529Kryštof Tulinger echo " -h|--help display this message and exit"
4ff40998447db64e675e85cda2bf3ae286b71529Kryštof Tulinger echo " -n|--type type of the message (default normal)"
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)"
4ff40998447db64e675e85cda2bf3ae286b71529Kryštof Tulinger echo " -u|--expire-timestamp explicit UTC timestamp for expiration in sec"
4095b5839a2805b2313532c995ad3d444f596d03Kryštof Tulinger echo " (*) see man date: option --date (requires GNU date - use DATE env variable)"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo " css classes: success, info, warning, error"
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 " See the code for more information on configuration options /" \
ec54ba43cd8a6f162c2052976cc8364f3a2441e5Kryštof Tulinger ${JAVA_CLASSPATH:+-classpath} ${JAVA_CLASSPATH} \
ec54ba43cd8a6f162c2052976cc8364f3a2441e5Kryštof Tulinger ${MESSAGE_TYPE:+-m} ${MESSAGE_TYPE:+"$MESSAGE_TYPE"} \
ec54ba43cd8a6f162c2052976cc8364f3a2441e5Kryštof Tulinger ${MESSAGE_CLASS:+-c} ${MESSAGE_CLASS:+"$MESSAGE_CLASS"} \
ec54ba43cd8a6f162c2052976cc8364f3a2441e5Kryštof Tulinger ${MESSAGE_EXPIRE_TIMESTAMP:+-e} ${MESSAGE_EXPIRE_TIMESTAMP:+"$MESSAGE_EXPIRE_TIMESTAMP"} \
ec54ba43cd8a6f162c2052976cc8364f3a2441e5Kryštof Tulinger ${REMOTE_SERVER:+-s} ${REMOTE_SERVER:+"$REMOTE_SERVER"} \
ec54ba43cd8a6f162c2052976cc8364f3a2441e5Kryštof Tulinger ${REMOTE_PORT_NUM:+-p} ${REMOTE_PORT_NUM:+"$REMOTE_PORT_NUM"} \
ec54ba43cd8a6f162c2052976cc8364f3a2441e5Kryštof Tulinger ${MESSAGE_TEXT:+-t} ${MESSAGE_TEXT:+"$MESSAGE_TEXT"} \
ec54ba43cd8a6f162c2052976cc8364f3a2441e5Kryštof Tulinger echo -e "\tJAVA_CLASSPATH = "${JAVA_CLASSPATH}
ec54ba43cd8a6f162c2052976cc8364f3a2441e5Kryštof Tulinger echo -e "\tOPENGROK_CONFIGURATION = "${OPENGROK_CONFIGURATION}
ec54ba43cd8a6f162c2052976cc8364f3a2441e5Kryštof Tulinger echo -e "\tOPENGROK_STANDARD_ENV = "${OPENGROK_STANDARD_ENV}
ec54ba43cd8a6f162c2052976cc8364f3a2441e5Kryštof Tulinger echo -e "\tOPENGROK_DISTRIBUTION_BASE = "${OPENGROK_DISTRIBUTION_BASE}
ec54ba43cd8a6f162c2052976cc8364f3a2441e5Kryštof Tulinger echo -e "\tREMOTE_SERVER = "${REMOTE_SERVER:-$REMOTE_SERVER}
ec54ba43cd8a6f162c2052976cc8364f3a2441e5Kryštof Tulinger echo -e "\tREMOTE_PORT_NUM = "${REMOTE_PORT_NUM:-$REMOTE_PORT_NUM}
ec54ba43cd8a6f162c2052976cc8364f3a2441e5Kryštof Tulinger echo -e "\tMESSAGE_TYPE = "${MESSAGE_TYPE:-$MESSAGE_TYPE}
ec54ba43cd8a6f162c2052976cc8364f3a2441e5Kryštof Tulinger echo -e "\tMESSAGE_TAGS = "${MESSAGE_TAGS[*]:-${MESSAGE_TAGS[*]}}
ec54ba43cd8a6f162c2052976cc8364f3a2441e5Kryštof Tulinger echo -e "\tMESSAGE_CLASS = "${MESSAGE_CLASS:-$MESSAGE_CLASS}
ec54ba43cd8a6f162c2052976cc8364f3a2441e5Kryštof Tulinger echo -e "\tMESSAGE_EXPIRE = "${MESSAGE_EXPIRE:-$MESSAGE_EXPIRE}
ec54ba43cd8a6f162c2052976cc8364f3a2441e5Kryštof Tulinger echo -e "\tMESSAGE_EXPIRE_TIMESTAMP = "${MESSAGE_EXPIRE_TIMESTAMP:-$MESSAGE_EXPIRE_TIMESTAMP}
ec54ba43cd8a6f162c2052976cc8364f3a2441e5Kryštof Tulinger echo -e "\tMESSAGE_TEXT = "${MESSAGE_TEXT:-$MESSAGE_TEXT}
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger# Find and load relevant configuration
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger# Taken (and modified) from original OpenGrok shell wrapper
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger Progress "Loading ${OPENGROK_STANDARD_ENV} ..."
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger if [ -n "${OPENGROK_CONFIGURATION}" -a -f "${OPENGROK_CONFIGURATION}" ]
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger # Load the Local OpenGrok Configuration Environment
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger Progress "Loading ${OPENGROK_CONFIGURATION} ..."
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger -f "${SCRIPT_DIRECTORY}/../dist/opengrok.jar" -a \
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger -f "${SCRIPT_DIRECTORY}/../dist/source.war" \
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger OPENGROK_DISTRIBUTION_BASE="${SCRIPT_DIRECTORY}/../dist"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger OPENGROK_DISTRIBUTION_BASE="${SCRIPT_DIRECTORY}/../lib"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger OPENGROK_JAR="${OPENGROK_JAR:-${OPENGROK_DISTRIBUTION_BASE}/opengrok.jar}"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger JAVA_CLASSPATH="${JAVA_CLASSPATH}:${OPENGROK_JAR}"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger MAIN_CLASS="org.opensolaris.opengrok.configuration.messages.Messages"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger# Find java home based on your system information
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger# Taken from original OpenGrok shell wrapper
ec54ba43cd8a6f162c2052976cc8364f3a2441e5Kryštof Tulinger echo "Cannot determine operating system version"
ec54ba43cd8a6f162c2052976cc8364f3a2441e5Kryštof Tulinger SunOS:5.10) javaHome="/usr/jdk/instances/jdk1.7.0" ;;
ec54ba43cd8a6f162c2052976cc8364f3a2441e5Kryštof Tulinger Darwin:*) javaHome=`/usr/libexec/java_home` ;;
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger javaHome=`ls -l /etc/alternatives/java | cut -f 2 -d \> `
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo "Bad syntax. Expecting some arguments."
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo "Maybe try --help option?"
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger MESSAGE_EXPIRE_TIMESTAMP=$(OneArgument "$@")
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo "Uknown option \"$opt\"" && Usage && exit 5
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 break # exit the while cycle
838924562130977ca1a3d3839d146fcda39ea1afKryštof Tulinger echo "Bad syntax. The text must be specified only once."
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 MESSAGE_EXPIRE_TIMESTAMP=`"$DATE" --date="$MESSAGE_EXPIRE" +"%s"`
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[ -z "${MESSAGE_TAGS[*]}" ] && MESSAGE_TAGS=(-g 'main')