Last active
February 24, 2017 11:25
-
-
Save zhongl/50b42ed44c21f6e9eff7a817e682421c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# This is a script to download easeagent-sm.jar and export JAVA_OPTS for a JVM application. | |
# Usage: | |
# source /dev/stdin <<< "$(curl -SL https://git.io/vD7Bp)" | |
JAR='easeagent-sm.jar' | |
URL="https://github.com/hexdecteam/stagemonitor/releases/download/v0.25.1-easestack/${JAR}" | |
DIR="${HOME}/.easestack" | |
function download { | |
mkdir -p $DIR | |
curl -Lk $URL -o $DIR/$JAR | |
result=$? | |
if [ $result -ne 0 ]; then | |
rm -rf $DIR/$JAR | |
fi | |
return $result | |
} | |
function check_required_envs { | |
echo "checking required environment variables..." | |
if [ -z $EA_LOG_CONF ]; then | |
echo 'Missing $EA_LOG_CONF' | |
return 1 | |
fi | |
if [ -z $EA_APP_CONF ]; then | |
echo 'Missing $EA_APP_CONF' | |
return 1 | |
fi | |
return 0 | |
} | |
function download_if_absent { | |
if [ -f "${DIR}/${JAR}" ]; then | |
echo "${DIR}/${JAR} was found." | |
else | |
echo "Download ${JAR} to ${DIR} ..." | |
download | |
return $? | |
fi | |
} | |
check_required_envs && download_if_absent && export JAVA_OPTS="$JAVA_OPTS -Deaseagent.log.conf=${EA_LOG_CONF} -javaagent:${DIR}/${JAR}=${EA_APP_CONF}" && echo done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
HOSTNAME
andHOSTIPV4
application.conf
andlog4j2.xml
file path.