Skip to content

Instantly share code, notes, and snippets.

@zhongl
Last active February 24, 2017 11:25
Show Gist options
  • Save zhongl/50b42ed44c21f6e9eff7a817e682421c to your computer and use it in GitHub Desktop.
Save zhongl/50b42ed44c21f6e9eff7a817e682421c to your computer and use it in GitHub Desktop.
#! /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
@zhongl
Copy link
Author

zhongl commented Feb 21, 2017

  • Resolve default value for HOSTNAME and HOSTIPV4
  • Support configure application.conf and log4j2.xml file path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment