2 ##############################################################################
4 # - Copyright 2015, 2016 AT&T Intellectual Properties
5 ##############################################################################
7 ROOT_DIR=${INSTALL_ROOT}${distFilesRootDirPath}
8 COMMON_DIR=${INSTALL_ROOT}${distFilesRootDirPath}/../../common
9 LRM_XML=${ROOT_DIR}/etc/lrm-${artifactId}.xml
10 LOGGING_PROP_FILE=${ROOT_DIR}/etc/log4j.properties
11 LOGGER_PROP_FILE=${ROOT_DIR}/etc/logging.props
12 AAFLOGIN=${ROOT_DIR}/bin/aaflogin
13 JAVA_HOME=/opt/java/jdk/jdk180
14 JAVA=$JAVA_HOME/bin/java
15 CADI_JAR=`ls $ROOT_DIR/lib/cadi-core*.jar`
19 mkdir -p logs || fail 1 "Error on creating the logs directory."
20 mkdir -p back || fail 1 "Error on creating the back directory."
21 chmod 777 back || fail 1 "Error on creating the back directory."
24 # Some Functions that Vastly cleanup this install file...
25 # You wouldn't believe how ugly it was before. Unreadable... JG
35 # Set the "SED" replacement for this Variable. Error if missing
36 # Note that Variable in the Template is surrounded by "_" i.e. _ROOT_DIR_
42 ERRS+="\n\t$1 must be set for this installation"
44 SED_E+=" -e s|$1|$2|g"
48 # Set the "SED" replacement for this Variable. Use Default (3rd parm) if missing
49 # Note that Variable in the Template is surrounded by "_" i.e. _ROOT_DIR_
56 SED_E+=" -e s|$1|$3|g"
58 SED_E+=" -e s|$1|$2|g"
64 # For each Password passed in:
65 # If Password starts with "enc:???", then replace it as is
66 # If not, then check for CADI_KEYFILE... see next
67 # If the CADI_KEYFILE is set, the utilize this as the CADI Keyfile
68 # If it does not exist, create it, and change to "0400" mode
69 # Utilize the Java and "cadi-core" found in Library to
70 # Encrypt Password with Keyfile, prepending "enc:???"
74 # Test if var exists, and is required
76 if [ "${!1}" = "" ]; then
77 if [ "${2}" = "required" ]; then
78 ERRS+="\n\t$1 must be set for this installation"
82 # Test if needs encrypting
84 if [[ ${!1} = enc:* ]]; then
85 SED_E+=" -e s|_${1}_|${!1}|g"
87 if [ "${CADI_KEYFILE}" != "" ] && [ -e "${CADI_JAR}" ]; then
89 # Create or use Keyfile listed in CADI_KEYFILE
91 if [ -e "${CADI_KEYFILE}" ]; then
92 if [ "$REPORTED_CADI_KEYFILE" = "" ]; then
93 echo "Using existing CADI KEYFILE (${CADI_KEYFILE})"
94 REPORTED_CADI_KEYFILE=true
97 echo "Creating CADI_KEYFILE (${CADI_KEYFILE})"
98 $JAVA -jar $CADI_JAR keygen ${CADI_KEYFILE}
99 chmod 0400 ${CADI_KEYFILE}
102 PASS=`$JAVA -jar $CADI_JAR digest ${!1} ${CADI_KEYFILE}`
103 SED_E+=" -e s|_${1}_|enc:$PASS|g"
105 if [ "$REPORTED_CADI_KEYFILE" = "" ]; then
106 if [ "${CADI_KEYFILE}" = "" ]; then
107 ERRS+="\n\tCADI_KEYFILE must be set for this installation"
109 if [ ! -e "${CADI_JAR}" ]; then
110 ERRS+="\n\t${CADI_JAR} must exist to deploy passwords"
112 REPORTED_CADI_KEYFILE=true
119 # Linux requires this. Mac blows with it. Who knows if Windoze even does SED
120 if [ -z "$SED_OPTS" ]; then
127 # Use "default" function if there is a property that isn't required, but can be defaulted
128 # use "required" function if the property must be set by the environment
130 required _ROOT_DIR_ ${ROOT_DIR}
131 default _COMMON_DIR_ ${AUTHZ_COMMON_DIR} ${COMMON_DIR}
132 required _JAVA_HOME_ ${JAVA_HOME}
133 required _SCLD_PLATFORM_ ${SCLD_PLATFORM}
134 required _HOSTNAME_ ${TARGET_HOSTNAME_FQ}
135 required _ARTIFACT_ID_ ${artifactId}
136 default _ARTIFACT_VERSION_ ${AFTSWM_ACTION_NEW_VERSION}
137 default _RESOURCE_REGISTRATION_ ${RESOURCE_REGISTRATION} true
138 default _AUTHZ_DATA_DIR_ ${AUTHZ_DATA_DIR} ${ROOT_DIR}/../../data
139 default _CM_URL_ ${CM_URL} ""
141 # Specifics for Service
142 if [ "${artifactId}" = "authz-service" ]; then
143 PROPERTIES_FILE=${ROOT_DIR}/etc/authAPI.props
144 default _RESOURCE_MIN_COUNT_ ${RESOURCE_MIN_COUNT} 1
145 default _RESOURCE_MAX_COUNT_ ${RESOURCE_MAX_COUNT} 5
146 required _AUTHZ_SERVICE_PORT_RANGE_ ${AUTHZ_SERVICE_PORT_RANGE}
148 elif [ "${artifactId}" = "authz-gui" ]; then
149 PROPERTIES_FILE=${ROOT_DIR}/etc/authGUI.props
150 required _AUTHZ_GUI_PORT_RANGE_ ${AUTHZ_GUI_PORT_RANGE}
151 default _RESOURCE_MIN_COUNT_ ${RESOURCE_MIN_COUNT} 1
152 default _RESOURCE_MAX_COUNT_ ${RESOURCE_MAX_COUNT} 2
154 elif [ "${artifactId}" = "authz-gw" ]; then
155 PROPERTIES_FILE=${ROOT_DIR}/etc/authGW.props
156 default _AUTHZ_GW_PORT_RANGE_ ${AUTHZ_GW_PORT_RANGE} 8095-8095
157 default _RESOURCE_MIN_COUNT_ 1
158 default _RESOURCE_MAX_COUNT_ 1
160 elif [ "${artifactId}" = "authz-fs" ]; then
161 PROPERTIES_FILE=${ROOT_DIR}/etc/FileServer.props
162 OTHER_FILES=${ROOT_DIR}/data/test.html
163 default _AUTHZ_FS_PORT_RANGE_ ${AUTHZ_FS_PORT_RANGE} 8096-8096
164 default _RESOURCE_MIN_COUNT_ 1
165 default _RESOURCE_MAX_COUNT_ 1
167 elif [ "${artifactId}" = "authz-certman" ]; then
168 PROPERTIES_FILE=${ROOT_DIR}/etc/certman.props
169 default _AUTHZ_CERTMAN_PORT_RANGE_ ${AUTHZ_CERTMAN_PORT_RANGE} 8150-8159
170 default _RESOURCE_MIN_COUNT_ 1
171 default _RESOURCE_MAX_COUNT_ 1
172 elif [ "${artifactId}" = "authz-batch" ]; then
173 PROPERTIES_FILE=${ROOT_DIR}/etc/authBatch.props
175 OTHER_FILES=`find ${ROOT_DIR}/bin -depth -type f`
177 default _RESOURCE_MIN_COUNT_ 1
178 default _RESOURCE_MAX_COUNT_ 1
179 required _AUTHZ_GUI_URL_ ${AUTHZ_GUI_URL}
184 if [ "${DME2_FS}" != "" ]; then
185 SED_E+=" -e s|_DME2_FS_|-DDME2_EP_REGISTRY_CLASS=DME2FS\$\{AAF_SPACE\}-DAFT_DME2_EP_REGISTRY_FS_DIR=${DME2_FS}|g"
187 SED_E+=" -e s|_DME2_FS_||g"
191 default _EMAIL_FROM_ ${EMAIL_FROM} authz@ems.att.com
192 default _EMAIL_HOST_ ${EMAIL_HOST} mailhost.att.com
193 default _ROUTE_OFFER_ ${ROUTE_OFFER} BAU_SE
194 default _DME_TIMEOUT_ ${DME_TIMEOUT} 3000
196 # Choose defaults for log level and logfile size
197 if [ "${SCLD_PLATFORM}" = "PROD" ]; then
201 default _AFT_ENVIRONMENT_ ${AFT_ENVIRONMENT} AFTUAT
202 default _ENV_CONTEXT_ ${ENV_CONTEXT} DEV
203 default _LOG4J_LEVEL_ ${LOG4J_LEVEL} WARN
204 default _LOG4J_SIZE_ ${LOG4J_SIZE} 10000KB
205 default _LOG_DIR_ ${LOG_DIR} ${ROOT_DIR}/logs
206 default _MAX_LOG_FILE_SIZE_ ${MAX_LOG_FILE_SIZE} 10000KB
207 default _MAX_LOG_FILE_BACKUP_COUNT_ ${MAX_LOG_FILE_BACKUP_COUNT} 7
209 if [ "${artifactId}" != "authz-batch" ]; then
210 required _LRM_XML_ ${LRM_XML}
212 required _AFT_LATITUDE_ ${LATITUDE}
213 required _AFT_LONGITUDE_ ${LONGITUDE}
214 required _HOSTNAME_ ${HOSTNAME}
216 required _PROPERTIES_FILE_ ${PROPERTIES_FILE}
217 required _LOGGING_PROP_FILE_ ${LOGGING_PROP_FILE}
220 default _MAJOR_VER_ "`expr ${version} : '\([0-9]*\)\..*'`"
221 default _MINOR_VER_ "`expr ${version} : '[0-9]*\.\([0-9]*\)\..*'`"
222 default _PATCH_VER_ "`expr ${version} : '[0-9]\.[0-9]*\.\(.*\)'`"
224 # Now Fail if Required items are not set...
225 # Report all of them at once!
226 if [ "${ERRS}" != "" ] ; then
232 for i in ${PROPERTIES_FILE} ${LRM_XML} ${LOGGING_PROP_FILE} ${AAFLOGIN} ${OTHER_FILES} ; do
236 sed ${SED_E} -i'.sed' ${i} || fail 8 "could not sed ${i} "
237 mv -f ${i}.sed ${ROOT_DIR}/back
243 # Add the resource to LRM using the newly created/substituted XML file.
245 if [ -r ${LRM_XML} ]; then
246 ${LRM_HOME}/bin/lrmcli -addOrUpgrade -file ${LRM_XML} || fail 1 "Add to LRM Failed"
247 ${LRM_HOME}/bin/lrmcli -start -name com.att.authz.${artifactId} -version ${version} -routeoffer ${ROUTE_OFFER} | grep SUCCESS
251 # Note: Must exit 0 or, it will be exit default 1 and fail