Last active
August 9, 2018 20:15
-
-
Save 0x1b-xyz/355b7b25491e791bfaeb5107f535400e 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 | |
echo "Writing DATATIME_* environment variables out to a properties file ..." | |
echo "" > ${DATATIME_HOME}/datatime.properties | |
for ENV in $(env); do | |
key="$( cut -d '=' -f 1 <<< "${ENV}" )" | |
val="$( cut -d '=' -f 2- <<< "${ENV}" )" | |
if [[ ${key} == DATATIME_* ]]; then | |
key=$(echo $key | tr _ . | tr '[:upper:]' '[:lower:]') | |
echo "Copying datatime.properties value from environment: ${key}" | |
echo "${key} = ${val}" >> ${DATATIME_HOME}/datatime.properties | |
fi | |
done | |
# Here's one that converts the environment vars into lower camel case while stripping the TOMCAT_ off the front | |
for ENV in $(env); do | |
KEY="$( cut -d '=' -f 1 <<< "${ENV}" )" | |
VAL="$( cut -d '=' -f 2- <<< "${ENV}" )" | |
if [[ ${KEY} == TOMCAT_* ]]; then | |
PROP="tomcat.$(echo ${KEY} | sed 's/TOMCAT_//' | tr '[:upper:]' '[:lower:]' | sed -re 's~(_)(.)~\U\2~g')" | |
echo "Writing ${KEY} as ${PROP} to catalina.properties: ${VAL} ..." | |
echo "${PROP} = ${VAL}" >> ${CATALINA_HOME}/conf/catalina.properties | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment