sg481n | bd890c5 | 2017-08-28 12:11:35 -0400 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | ############################################################################## |
| 3 | # - Copyright 2012, 2016 AT&T Intellectual Properties |
| 4 | ############################################################################## |
| 5 | umask 022 |
| 6 | ROOT_DIR=${INSTALL_ROOT}/${distFilesRootDirPath} |
| 7 | LOGGING_PROP_FILE=${ROOT_DIR}/etc/log4j.properties |
| 8 | RUN_FILE=${ROOT_DIR}/etc/tconn.sh |
| 9 | |
| 10 | cd ${ROOT_DIR} |
| 11 | |
| 12 | mkdir -p logs || fail 1 "Error on creating the logs directory." |
| 13 | mkdir -p back || fail 1 "Error on creating the back directory." |
| 14 | chmod 777 back || fail 1 "Error on creating the back directory." |
| 15 | |
| 16 | # |
| 17 | # Some Functions that Vastly cleanup this install file... |
| 18 | # You wouldn't believe how ugly it was before. Unreadable... JG |
| 19 | # |
| 20 | fail() { |
| 21 | rc=$1 |
| 22 | shift; |
| 23 | echo "ERROR: $@" |
| 24 | exit $rc |
| 25 | } |
| 26 | |
| 27 | # |
| 28 | # Set the "SED" replacement for this Variable. Error if missing |
| 29 | # Note that Variable in the Template is surrounded by "_" i.e. _ROOT_DIR_ |
| 30 | # Replacement Name |
| 31 | # Value |
| 32 | # |
| 33 | required() { |
| 34 | if [ -z "$2" ]; then |
| 35 | ERRS+="\n\t$1 must be set for this installation" |
| 36 | fi |
| 37 | SED_E+=" -e s|$1|$2|g" |
| 38 | } |
| 39 | |
| 40 | # |
| 41 | # Set the "SED" replacement for this Variable. Use Default (3rd parm) if missing |
| 42 | # Note that Variable in the Template is surrounded by "_" i.e. _ROOT_DIR_ |
| 43 | # Replacement Name |
| 44 | # Value |
| 45 | # Default Value |
| 46 | # |
| 47 | default() { |
| 48 | if [ -z "$2" ]; then |
| 49 | SED_E+=" -e s|$1|$3|g" |
| 50 | else |
| 51 | SED_E+=" -e s|$1|$2|g" |
| 52 | fi |
| 53 | } |
| 54 | |
| 55 | # Linux requires this. Mac blows with it. Who knows if Windoze even does SED |
| 56 | if [ -z "$SED_OPTS" ]; then |
| 57 | SED_E+=" -c " |
| 58 | else |
| 59 | SED_E+=$SED_OPTS; |
| 60 | fi |
| 61 | |
| 62 | |
| 63 | # |
| 64 | # Use "default" function if there is a property that isn't required, but can be defaulted |
| 65 | # use "required" function if the property must be set by the environment |
| 66 | # |
| 67 | required _ROOT_DIR_ ${ROOT_DIR} |
| 68 | default _COMMON_DIR_ ${COMMON_DIR} ${ROOT_DIR}/../../common |
| 69 | required _AFT_ENVIRONMENT_ ${AFT_ENVIRONMENT} |
| 70 | required _ENV_CONTEXT_ ${ENV_CONTEXT} |
| 71 | required _HOSTNAME_ ${HOSTNAME} |
| 72 | required _ARTIFACT_ID_ ${artifactId} |
| 73 | required _ARTIFACT_VERSION_ ${version} |
| 74 | |
| 75 | # Specifics for Service |
| 76 | if [ "${artifactId}" = "authz-service" ]; then |
| 77 | default _AUTHZ_SERVICE_PORT_ ${PORT} 0 |
| 78 | required _AUTHZ_CASS_CLUSTERS_ ${AUTHZ_CASS_CLUSTERS} |
| 79 | required _AUTHZ_CASS_PORT_ ${AUTHZ_CASS_PORT} |
| 80 | required _AUTHZ_CASS_PWD_ ${AUTHZ_CASS_PWD} |
| 81 | default _AUTHZ_CASS_USER_ ${AUTHZ_CASS_USER} authz |
| 82 | required _AUTHZ_KEYSTORE_PASSWORD_ ${AUTHZ_KEYSTORE_PASSWORD} |
| 83 | required _AUTHZ_KEY_PASSWORD_ ${AUTHZ_KEY_PASSWORD} |
| 84 | required _SCLD_PLATFORM_ ${SCLD_PLATFORM} |
| 85 | fi |
| 86 | |
| 87 | default _EMAIL_FROM_ ${EMAIL_FROM} authz@ems.att.com |
| 88 | default _EMAIL_HOST_ ${EMAIL_HOST} mailhost.att.com |
| 89 | default _ROUTE_OFFER_ ${ROUTE_OFFER} BAU_SE |
| 90 | default _DME_TIMEOUT_ ${DME_TIMEOUT} 3000 |
| 91 | |
| 92 | # Choose defaults for log level and logfile size |
| 93 | if [ "${SCLD_PLATFORM}" = "PROD" ]; then |
| 94 | LOG4J_LEVEL=WARN |
| 95 | fi |
| 96 | default _LOG4J_LEVEL_ ${LOG4J_LEVEL} INFO |
| 97 | default _LOG4J_SIZE_ ${LOG4J_SIZE} 10000KB |
| 98 | default _LOG_DIR_ ${LOG_DIR} ${ROOT_DIR}/logs |
| 99 | default _MAX_LOG_FILE_SIZE_ ${MAX_LOG_FILE_SIZE} 10000KB |
| 100 | default _MAX_LOG_FILE_BACKUP_COUNT_ ${MAX_LOG_FILE_BACKUP_COUNT} 7 |
| 101 | default _RESOURCE_MIN_COUNT_ ${RESOURCE_MIN_COUNT} 1 |
| 102 | default _RESOURCE_MAX_COUNT_ ${RESOURCE_MAX_COUNT} 1 |
| 103 | |
| 104 | required _LOGGING_PROP_FILE_ ${LOGGING_PROP_FILE} |
| 105 | required _AFT_LATITUDE_ ${LATITUDE} |
| 106 | required _AFT_LONGITUDE_ ${LONGITUDE} |
| 107 | required _HOSTNAME_ ${HOSTNAME} |
| 108 | |
| 109 | # Divide up Version |
| 110 | default _MAJOR_VER_ "`expr ${version} : '\([0-9]*\)\..*'`" |
| 111 | default _MINOR_VER_ "`expr ${version} : '[0-9]*\.\([0-9]*\)\..*'`" |
| 112 | default _PATCH_VER_ "`expr ${version} : '[0-9]\.[0-9]*\.\(.*\)'`" |
| 113 | |
| 114 | |
| 115 | |
| 116 | # Now Fail if Required items are not set... |
| 117 | # Report all of them at once! |
| 118 | if [ "${ERRS}" != "" ] ; then |
| 119 | fail 1 "${ERRS}" |
| 120 | fi |
| 121 | |
| 122 | #echo ${SED_E} |
| 123 | |
| 124 | for i in ${PROPERTIES_FILE} ${LRM_XML} ${LOGGING_PROP_FILE} ${RUN_FILE} ; do |
| 125 | if [ -r ${i} ]; then |
| 126 | if [ -w ${i} ]; then |
| 127 | # echo ${i} |
| 128 | sed ${SED_E} -i'.sed' ${i} || fail 8 "could not sed ${i} " |
| 129 | mv -f ${i}.sed ${ROOT_DIR}/back |
| 130 | fi |
| 131 | fi |
| 132 | done |
| 133 | |
| 134 | # |
| 135 | # Add the resource to LRM using the newly created/substituted XML file. |
| 136 | # |
| 137 | # Note: No LRM for authz-test |
| 138 | #if [ -r ${LRM_XML} ]; then |
| 139 | # ${LRM_HOME}/bin/lrmcli -addOrUpgrade -file ${LRM_XML} || fail 1 "Add to LRM Failed" |
| 140 | # ${LRM_HOME}/bin/lrmcli -start -name com.att.authz.${artifactId} -version ${version} -routeoffer ${ROUTE_OFFER} | grep SUCCESS |
| 141 | #fi |
| 142 | # |
| 143 | # Note: Must exit 0 or, it will be exit default 1 and fail |
| 144 | exit 0 |