@@ -20,12 +20,14 @@ source ${scriptDir}/../../common/utility.sh
20
20
source ${scriptDir} /../../common/validate.sh
21
21
22
22
function usage {
23
- echo usage: ${script} -o dir -i file -u username -p password [-e] [-h]
23
+ echo usage: ${script} -o dir -i file -u username -p password [-k] [- e] [-h]
24
24
echo " -i Parameter inputs file, must be specified."
25
25
echo " -o Ouput directory for the generated properties and YAML files, must be specified."
26
26
echo " -u Username used in building the Docker image for WebLogic domain in image."
27
27
echo " -p Password used in building the Docker image for WebLogic domain in image."
28
28
echo " -e Also create the resources in the generated YAML files, optional."
29
+ echo " -k Keep what has been previously from cloned https://github.com/oracle/docker-images.git, optional. "
30
+ echo " If not specified, this script will always remove existing project directory and clone again."
29
31
echo " -h Help"
30
32
exit $1
31
33
}
@@ -34,7 +36,8 @@ function usage {
34
36
# Parse the command line options
35
37
#
36
38
executeIt=false
37
- while getopts " evhi:o:u:p:" opt; do
39
+ cloneIt=true
40
+ while getopts " evhki:o:u:p:" opt; do
38
41
case $opt in
39
42
i) valuesInputFile=" ${OPTARG} "
40
43
;;
@@ -46,6 +49,8 @@ while getopts "evhi:o:u:p:" opt; do
46
49
;;
47
50
p) password=" ${OPTARG} "
48
51
;;
52
+ k) cloneIt=false;
53
+ ;;
49
54
h) usage 0
50
55
;;
51
56
* ) usage 1
81
86
# Function to initialize and validate the output directory
82
87
# for the generated properties and yaml files for this domain.
83
88
#
84
- function initAndValidateOutputDir {
89
+ function initOutputDir {
85
90
domainOutputDir=" ${outputDir} /weblogic-domains/${domainUID} "
86
91
# Create a directory for this domain's output files
87
92
mkdir -p ${domainOutputDir}
88
93
89
- validateOutputDir \
90
- ${domainOutputDir} \
91
- ${valuesInputFile} \
92
- create-domain-inputs.yaml \
93
- domain.properties \
94
- domain.yaml
95
- }
96
-
97
- #
98
- # Function to validate the domain secret
99
- #
100
- function validateDomainSecret {
101
- # Verify the secret exists
102
- validateSecretExists ${weblogicCredentialsSecretName} ${namespace}
103
- failIfValidationErrors
104
-
105
- # Verify the secret contains a username
106
- SECRET=` kubectl get secret ${weblogicCredentialsSecretName} -n ${namespace} -o jsonpath=' {.data}' | grep username: | wc | awk ' { print $1; }' `
107
- if [ " ${SECRET} " != " 1" ]; then
108
- validationError " The domain secret ${weblogicCredentialsSecretName} in namespace ${namespace} does contain a username"
109
- fi
110
-
111
- # Verify the secret contains a password
112
- SECRET=` kubectl get secret ${weblogicCredentialsSecretName} -n ${namespace} -o jsonpath=' {.data}' | grep password: | wc | awk ' { print $1; }' `
113
- if [ " ${SECRET} " != " 1" ]; then
114
- validationError " The domain secret ${weblogicCredentialsSecretName} in namespace ${namespace} does contain a password"
115
- fi
116
- failIfValidationErrors
117
- }
118
-
119
- #
120
- # Function to validate a kubernetes secret exists
121
- # $1 - the name of the secret
122
- # $2 - namespace
123
- function validateSecretExists {
124
- echo " Checking to see if the secret ${1} exists in namespace ${2} "
125
- local SECRET=` kubectl get secret ${1} -n ${2} | grep ${1} | wc | awk ' { print $1; }' `
126
- if [ " ${SECRET} " != " 1" ]; then
127
- validationError " The secret ${1} was not found in namespace ${2} "
128
- fi
94
+ removeFileIfExists ${domainOutputDir} /${valuesInputFile}
95
+ removeFileIfExists ${domainOutputDir} /create-domain-inputs.yaml
96
+ removeFileIfExists ${domainOutputDir} /domain.properties
97
+ removeFileIfExists ${domainOutputDir} /domain.yaml
129
98
}
130
99
131
100
# try to execute docker to see whether docker is available
@@ -170,54 +139,19 @@ function initialize {
170
139
171
140
failIfValidationErrors
172
141
173
- # Parse the commonn inputs file
174
- parseCommonInputs
175
-
176
- validateInputParamsSpecified \
177
- adminServerName \
178
- domainUID \
179
- clusterName \
180
- managedServerNameBase \
181
- namespace \
182
- t3PublicAddress \
183
- version
184
-
185
- validateIntegerInputParamsSpecified \
186
- adminPort \
187
- configuredManagedServerCount \
188
- initialManagedServerReplicas \
189
- managedServerPort \
190
- t3ChannelPort \
191
- adminNodePort
192
-
193
- validateBooleanInputParamsSpecified \
194
- productionModeEnabled \
195
- exposeAdminT3Channel \
196
- exposeAdminNodePort \
197
- includeServerOutInPodLog
198
-
199
- export requiredInputsVersion=" create-weblogic-sample-domain-inputs-v1"
200
- validateVersion
201
-
202
- validateDomainUid
203
- validateNamespace
204
- validateAdminServerName
205
- validateManagedServerNameBase
206
- validateClusterName
207
- validateWeblogicCredentialsSecretName
208
- initAndValidateOutputDir
209
- validateServerStartPolicy
210
- validateClusterType
211
- failIfValidationErrors
142
+ validateCommonInputs
143
+
144
+ initOutputDir
212
145
213
- getDockerSample
146
+ if [ " ${cloneIt} " = true ]; then
147
+ getDockerSample
148
+ fi
214
149
}
215
150
216
151
#
217
152
# Function to get the dependency docker sample
218
153
#
219
154
function getDockerSample {
220
- rm -rf {scriptDir}/docker-images
221
155
git clone https://github.com/oracle/docker-images.git
222
156
}
223
157
@@ -239,11 +173,17 @@ function createFiles {
239
173
enabledPrefix=" " # uncomment the feature
240
174
disabledPrefix=" # " # comment out the feature
241
175
242
- domainName=${domainUID}
176
+ domainName=${domainUID}
243
177
244
178
# Generate the properties file that will be used when creating the weblogic domain
245
179
echo Generating ${domainPropertiesOutput}
246
180
181
+ if [ " ${productionModeEnabled} " = true ]; then
182
+ serverStartMode=" prod"
183
+ else
184
+ serverStartMode=" dev"
185
+ fi
186
+
247
187
cp ${domainPropertiesInput} ${domainPropertiesOutput}
248
188
sed -i -e " s:%DOMAIN_NAME%:${domainName} :g" ${domainPropertiesOutput}
249
189
sed -i -e " s:%ADMIN_PORT%:${adminPort} :g" ${domainPropertiesOutput}
@@ -254,6 +194,7 @@ function createFiles {
254
194
sed -i -e " s:%CLUSTER_NAME%:${clusterName} :g" ${domainPropertiesOutput}
255
195
sed -i -e " s:%PRODUCTION_MODE_ENABLED%:${productionModeEnabled} :g" ${domainPropertiesOutput}
256
196
sed -i -e " s:%CLUSTER_TYPE%:${clusterType} :g" ${domainPropertiesOutput}
197
+ sed -i -e " s:%SERVER_START_MODE%:${serverStartMode} :g" ${domainPropertiesOutput}
257
198
sed -i -e " s:%JAVA_OPTIONS%:${javaOptions} :g" ${domainPropertiesOutput}
258
199
sed -i -e " s:%T3_CHANNEL_PORT%:${t3ChannelPort} :g" ${domainPropertiesOutput}
259
200
sed -i -e " s:%T3_PUBLIC_ADDRESS%:${t3PublicAddress} :g" ${domainPropertiesOutput}
@@ -304,20 +245,43 @@ function createFiles {
304
245
# Function to build docker image and create WebLogic domain home
305
246
#
306
247
function createDomainHome {
307
- cp ${domainPropertiesOutput} ./docker-images/OracleWebLogic/samples/12213-domain-home-in-image/properties/docker_build
308
-
309
- cd docker-images/OracleWebLogic/samples/12213-domain-home-in-image
248
+ if [ -z $imagePath ] ; then
249
+ imagePath= " 12213-domain-home-in-image-wdt "
250
+ fi
310
251
311
- sed -i -e " s|myuser|${username} |g" properties/docker_build/domain_security.properties
312
- sed -i -e " s|mypassword1|${password} |g" properties/docker_build/domain_security.properties
252
+ if [ -z $imageName ]; then
253
+ imageName=" ${imagePath} :latest"
254
+ fi
255
+ # now we know which image to use, update the domain yaml file
256
+ sed -i -e " s|%IMAGE_NAME%|${imageName} |g" ${dcrOutput}
257
+
258
+ dockerDir=${scriptDir} /docker-images/OracleWebLogic/samples/${imagePath}
259
+ dockerPropsDir=${dockerDir} /properties
260
+ cp ${domainPropertiesOutput} ${dockerPropsDir}
261
+
262
+ # 12213-domain-home-in-image use one properties file for the credentials
263
+ usernameFile=" ${dockerPropsDir} /docker_build/domain_security.properties"
264
+ passwordFile=" ${dockerPropsDir} /docker_build/domain_security.properties"
265
+
266
+ # 12213-domain-home-in-image-wdt uses two properties files for the credentials
267
+ if [ ! -f $usernameFile ]; then
268
+ usernameFile=" ${dockerPropsDir} /docker-build/adminuser.properties"
269
+ passwordFile=" ${dockerPropsDir} /docker-build/adminpass.properties"
270
+ fi
271
+
272
+ sed -i -e " s|myuser|${username} |g" $usernameFile
273
+ sed -i -e " s|mypassword1|${password} |g" $passwordFile
274
+
275
+ if [ ! -z $baseImage ]; then
276
+ sed -i -e " s|\(FROM \).*|\1 ${baseImage} |g" Dockerfile
277
+ fi
313
278
314
- . /build.sh
279
+ sh ${dockerDir} /build.sh
315
280
316
281
if [ " $? " != " 0" ]; then
317
282
fail " Create domain ${domainName} failed."
318
283
fi
319
284
320
- cd -
321
285
echo " "
322
286
echo " Create domain ${domainName} successfully."
323
287
}
@@ -343,43 +307,10 @@ function printSummary {
343
307
echo " ${domainOutputDir} /create-domain-inputs.yaml"
344
308
echo " ${domainPropertiesOutput} "
345
309
echo " ${dcrOutput} "
310
+ echo " "
311
+ echo " Completed"
346
312
}
347
313
348
- #
349
- # Function to create the domain resource
350
- #
351
- function createDomainResource {
352
- pwd
353
- kubectl apply -f ${dcrOutput}
354
- DCR_AVAIL=` kubectl get domain -n ${namespace} | grep ${domainUID} | wc | awk ' { print $1; } ' `
355
- if [ " ${DCR_AVAIL} " != " 1" ]; then
356
- fail " The domain resource ${domainUID} was not found"
357
- fi
358
- }
359
-
360
- #
361
- # Perform the following sequence of steps to create a domain
362
- #
363
-
364
- # Setup the environment for running this script and perform initial validation checks
365
- initialize
366
-
367
- # Generate the properties and yaml files for creating the domain
368
- createFiles
369
-
370
- # Check that the domain secret exists and contains the required elements
371
- validateDomainSecret
372
-
373
- # Create the WebLogic domain
374
- createDomainHome
375
-
376
- if [ " ${executeIt} " = true ]; then
377
- createDomainResource
378
- fi
379
-
380
- # Print a summary
381
- printSummary
382
-
383
- echo
384
- echo Completed
314
+ # Perform the sequence of steps to create a domain
315
+ createDomain
385
316
0 commit comments