21
21
22
22
# Get the User OCID
23
23
while ! state_done USER_OCID; do
24
- read -p " Please enter your OCI user's OCID: " USER_OCID
24
+ if test -z " $TEST_USER_OCID " ; then
25
+ read -p " Please enter your OCI user's OCID: " USER_OCID
26
+ else
27
+ USER_OCID=$TEST_USER_OCID
28
+ fi
25
29
# Validate
26
30
if test " " ` oci iam user get --user-id " $USER_OCID " --query ' data."lifecycle-state"' --raw-output 2> $GRABDISH_LOG /user_ocid_err` == ' ACTIVE' ; then
27
31
state_set USER_OCID " $USER_OCID "
@@ -47,7 +51,7 @@ while ! state_done RUN_TYPE; do
47
51
state_set RESERVATION_ID ` grep -oP ' (?<=LL).*?(?=-USER)' <<< " $(state_get USER_NAME)" `
48
52
state_set_done PROVISIONING
49
53
state_set RUN_NAME " grabdish$( state_get RESERVATION_ID) "
50
- state_set ORDER_DB_NAME " ORDERDB $( state_get RESERVATION_ID) "
54
+ state_set ORDER_DB_NAME " ORDER $( state_get RESERVATION_ID) "
51
55
state_set INVENTORY_DB_NAME " INVENTORY$( state_get RESERVATION_ID) "
52
56
state_set_done OKE_LIMIT_CHECK
53
57
state_set_done ATP_LIMIT_CHECK
@@ -57,46 +61,6 @@ while ! state_done RUN_TYPE; do
57
61
done
58
62
59
63
60
- # Check OKE Limits
61
- if ! state_done OKE_LIMIT_CHECK; then
62
- # Cluster Service Limit
63
- OKE_LIMIT=` oci limits value list --compartment-id " $OCI_TENANCY " --service-name " container-engine" --query ' sum(data[?"name"==' " 'cluster-count'" ' ].value)' `
64
- if test " $OKE_LIMIT " -lt 1; then
65
- echo ' The service limit for the "Container Engine" "Cluster Count" is insufficent to run this workshop. At least 1 is required.'
66
- exit
67
- elif test " $OKE_LIMIT " -eq 1; then
68
- echo ' You are limited to only one OKE cluster in this tenancy. This workshop will create one additional OKE cluster and so any other OKE clusters must be terminated.'
69
- read -p " Please confirm that no other un-terminated OKE clusters exist in this tenancy and then hit [RETURN]? " DUMMY
70
- fi
71
- state_set_done OKE_LIMIT_CHECK
72
- fi
73
-
74
-
75
- # Check ATP resource availability
76
- while ! state_done ATP_LIMIT_CHECK; do
77
- CHECK=1
78
- # ATP OCPU availability
79
- if test $( oci limits resource-availability get --compartment-id=" $OCI_TENANCY " --service-name " database" --limit-name " atp-ocpu-count" --query ' to_string(min([data."fractional-availability",`4.0`]))' --raw-output) ! = ' 4.0' ; then
80
- echo ' The "Autonomous Transaction Processing OCPU Count" resource availability is insufficent to run this workshop.'
81
- echo ' 4 OCPUs are required. Terminate some existing ATP databases and try again.'
82
- CHECK=0
83
- fi
84
-
85
- # ATP storage availability
86
- if test $( oci limits resource-availability get --compartment-id=" $OCI_TENANCY " --service-name " database" --limit-name " atp-total-storage-tb" --query ' to_string(min([data."fractional-availability",`2.0`]))' --raw-output) ! = ' 2.0' ; then
87
- echo ' The "Autonomous Transaction Processing Total Storage (TB)" resource availability is insufficent to run this workshop.'
88
- echo ' 2 TB are required. Terminate some existing ATP databases and try again.'
89
- CHECK=0
90
- fi
91
-
92
- if test $CHECK -eq 1; then
93
- state_set_done ATP_LIMIT_CHECK
94
- else
95
- read -p " Hit [RETURN] when you are ready to retry? " DUMMY
96
- fi
97
- done
98
-
99
-
100
64
# Get Run Name from directory name
101
65
while ! state_done RUN_NAME; do
102
66
cd $GRABDISH_HOME
@@ -145,29 +109,14 @@ while ! state_done COMPARTMENT_OCID; do
145
109
else
146
110
read -p " Please enter your OCI compartments's OCID: " COMPARTMENT_OCID
147
111
fi
148
- while ! test ` oci iam compartment get --compartment-id " $COMPARTMENT_OCID " --query ' data."lifecycle-state"' --raw-output` " " == ' ACTIVE' ; do
112
+ while ! test ` oci iam compartment get --compartment-id " $COMPARTMENT_OCID " --query ' data."lifecycle-state"' --raw-output` " " == ' ACTIVE' 2> /dev/null ; do
149
113
echo " Waiting for the compartment to become ACTIVE"
150
114
sleep 2
151
115
done
152
116
state_set COMPARTMENT_OCID " $COMPARTMENT_OCID "
153
117
done
154
118
155
119
156
- # Switch to SSH Key auth for the oci cli (workaround to perm issue awaiting fix)
157
- # source $GRABDISH_HOME/utils/oci-cli-cs-key-auth.sh
158
-
159
-
160
- # Run the terraform.sh in the background
161
- if ! state_get PROVISIONING; then
162
- if ps -ef | grep " $GRABDISH_HOME /utils/terraform.sh" | grep -v grep; then
163
- echo " $GRABDISH_HOME /utils/terraform.sh is already running"
164
- else
165
- echo " Executing terraform.sh in the background"
166
- nohup $GRABDISH_HOME /utils/terraform.sh & >> $GRABDISH_LOG /terraform.log &
167
- fi
168
- fi
169
-
170
-
171
120
# # Run the java-builds.sh in the background
172
121
if ! state_get JAVA_BUILDS; then
173
122
if ps -ef | grep " $GRABDISH_HOME /utils/java-builds.sh" | grep -v grep; then
@@ -190,6 +139,59 @@ if ! state_get NON_JAVA_BUILDS; then
190
139
fi
191
140
192
141
142
+ # Check OKE Limits
143
+ if ! state_done OKE_LIMIT_CHECK; then
144
+ # Cluster Service Limit
145
+ OKE_LIMIT=` oci limits value list --compartment-id " $OCI_TENANCY " --service-name " container-engine" --query ' sum(data[?"name"==' " 'cluster-count'" ' ].value)' `
146
+ if test " $OKE_LIMIT " -lt 1; then
147
+ echo ' The service limit for the "Container Engine" "Cluster Count" is insufficent to run this workshop. At least 1 is required.'
148
+ exit
149
+ elif test " $OKE_LIMIT " -eq 1; then
150
+ echo ' You are limited to only one OKE cluster in this tenancy. This workshop will create one additional OKE cluster and so any other OKE clusters must be terminated.'
151
+ if test -z " $TEST_USER_OCID " ; then
152
+ read -p " Please confirm that no other un-terminated OKE clusters exist in this tenancy and then hit [RETURN]? " DUMMY
153
+ fi
154
+ fi
155
+ state_set_done OKE_LIMIT_CHECK
156
+ fi
157
+
158
+
159
+ # Check ATP resource availability
160
+ while ! state_done ATP_LIMIT_CHECK; do
161
+ CHECK=1
162
+ # ATP OCPU availability
163
+ if test $( oci limits resource-availability get --compartment-id=" $OCI_TENANCY " --service-name " database" --limit-name " atp-ocpu-count" --query ' to_string(min([data."fractional-availability",`4.0`]))' --raw-output) ! = ' 4.0' ; then
164
+ echo ' The "Autonomous Transaction Processing OCPU Count" resource availability is insufficent to run this workshop.'
165
+ echo ' 4 OCPUs are required. Terminate some existing ATP databases and try again.'
166
+ CHECK=0
167
+ fi
168
+
169
+ # ATP storage availability
170
+ if test $( oci limits resource-availability get --compartment-id=" $OCI_TENANCY " --service-name " database" --limit-name " atp-total-storage-tb" --query ' to_string(min([data."fractional-availability",`2.0`]))' --raw-output) ! = ' 2.0' ; then
171
+ echo ' The "Autonomous Transaction Processing Total Storage (TB)" resource availability is insufficent to run this workshop.'
172
+ echo ' 2 TB are required. Terminate some existing ATP databases and try again.'
173
+ CHECK=0
174
+ fi
175
+
176
+ if test $CHECK -eq 1; then
177
+ state_set_done ATP_LIMIT_CHECK
178
+ else
179
+ read -p " Hit [RETURN] when you are ready to retry? " DUMMY
180
+ fi
181
+ done
182
+
183
+
184
+ # # Run the terraform.sh in the background
185
+ if ! state_get PROVISIONING; then
186
+ if ps -ef | grep " $GRABDISH_HOME /utils/terraform.sh" | grep -v grep; then
187
+ echo " $GRABDISH_HOME /utils/terraform.sh is already running"
188
+ else
189
+ echo " Executing terraform.sh in the background"
190
+ nohup $GRABDISH_HOME /utils/terraform.sh & >> $GRABDISH_LOG /terraform.log &
191
+ fi
192
+ fi
193
+
194
+
193
195
# Get Namespace
194
196
while ! state_done NAMESPACE; do
195
197
export OCI_CLI_PROFILE=$( state_get HOME_REGION)
@@ -201,32 +203,36 @@ done
201
203
202
204
# login to docker
203
205
while ! state_done DOCKER_REGISTRY; do
204
- export OCI_CLI_PROFILE=$( state_get HOME_REGION)
205
- if ! TOKEN=` oci iam auth-token create --user-id " $( state_get USER_OCID) " --description ' grabdish docker login' --query ' data.token' --raw-output 2> $GRABDISH_LOG /docker_registry_err` ; then
206
- if grep UserCapacityExceeded $GRABDISH_LOG /docker_registry_err > /dev/null; then
207
- # The key already exists
208
- echo ' ERROR: Failed to create auth token. Please delete an old token from the OCI Console (Profile -> User Settings -> Auth Tokens).'
209
- read -p " Hit return when you are ready to retry?"
210
- else
211
- echo " ERROR: Creating auth token had failed:"
212
- cat $GRABDISH_LOG /docker_registry_err
213
- exit
214
- fi
215
- else
216
- sleep 5 # Allow time for the auth token to come into effect
217
- RETRIES=0
218
- while test $RETRIES -le 10; do
219
- if echo " $TOKEN " | docker login -u " $( state_get NAMESPACE) /$( state_get USER_NAME) " --password-stdin " $( state_get REGION) .ocir.io" ; then
220
- state_set DOCKER_REGISTRY " $( state_get REGION) .ocir.io/$( state_get NAMESPACE) /$( state_get RUN_NAME) "
221
- break
206
+ if test $( state_get RUN_TYPE) -ne 3; then
207
+ export OCI_CLI_PROFILE=$( state_get HOME_REGION)
208
+ if ! TOKEN=` oci iam auth-token create --user-id " $( state_get USER_OCID) " --description ' grabdish docker login' --query ' data.token' --raw-output 2> $GRABDISH_LOG /docker_registry_err` ; then
209
+ if grep UserCapacityExceeded $GRABDISH_LOG /docker_registry_err > /dev/null; then
210
+ # The key already exists
211
+ echo ' ERROR: Failed to create auth token. Please delete an old token from the OCI Console (Profile -> User Settings -> Auth Tokens).'
212
+ read -p " Hit return when you are ready to retry?"
213
+ continue
222
214
else
223
- echo " Docker login failed. Retrying "
224
- RETRIES= $(( RETRIES + 1 ))
225
- sleep 5
215
+ echo " ERROR: Creating auth token had failed: "
216
+ cat $GRABDISH_LOG /docker_registry_err
217
+ exit
226
218
fi
227
- done
219
+ fi
220
+ else
221
+ read -p " Please generate an Auth Token and enter the value: " TOKEN
228
222
fi
229
- export OCI_CLI_PROFILE=$( state_get REGION)
223
+
224
+ RETRIES=0
225
+ while test $RETRIES -le 30; do
226
+ if echo " $TOKEN " | docker login -u " $( state_get NAMESPACE) /$( state_get USER_NAME) " --password-stdin " $( state_get REGION) .ocir.io" & > /dev/null; then
227
+ state_set DOCKER_REGISTRY " $( state_get REGION) .ocir.io/$( state_get NAMESPACE) /$( state_get RUN_NAME) "
228
+ export OCI_CLI_PROFILE=$( state_get REGION)
229
+ break
230
+ else
231
+ # echo "Docker login failed. Retrying"
232
+ RETRIES=$(( RETRIES+ 1 ))
233
+ sleep 5
234
+ fi
235
+ done
230
236
done
231
237
232
238
@@ -261,8 +267,12 @@ if ! state_done DB_PASSWORD; then
261
267
echo
262
268
263
269
while true ; do
264
- read -s -r -p " Enter the password to be used for the order and inventory databases: " PW
265
- if [[ ${# PW} -ge 12 && ${# PW} -le 30 && " $PW " =~ [A-Z] && " $PW " =~ [a-z] && " $PW " =~ [0-9] && " $PW " != * admin* && " $PW " != * ' "' * ]]; then
270
+ if test -z " $TEST_DB_PASSWORD " ; then
271
+ read -s -r -p " Enter the password to be used for the order and inventory databases: " PW
272
+ else
273
+ PW=" $TEST_DB_PASSWORD "
274
+ fi
275
+ if [[ ${# PW} -ge 12 && ${# PW} -le 30 && " $PW " =~ [A-Z] && " $PW " =~ [a-z] && " $PW " =~ [0-9] && " $PW " != * admin* && " $PW " != * ' "' * ]]; then
266
276
echo
267
277
break
268
278
else
@@ -280,8 +290,12 @@ if ! state_done UI_PASSWORD; then
280
290
echo
281
291
282
292
while true ; do
283
- read -s -r -p " Enter the password to be used for accessing the UI: " PW
284
- if [[ ${# PW} -ge 8 && ${# PW} -le 30 ]]; then
293
+ if test -z " $TEST_UI_PASSWORD " ; then
294
+ read -s -r -p " Enter the password to be used for accessing the UI: " PW
295
+ else
296
+ PW=" $TEST_UI_PASSWORD "
297
+ fi
298
+ if [[ ${# PW} -ge 8 && ${# PW} -le 30 ]]; then
285
299
echo
286
300
break
287
301
else
@@ -392,6 +406,13 @@ while ! state_done INVENTORY_DB_PASSWORD_SET; do
392
406
done
393
407
394
408
409
+ # Wait for OKE Setup
410
+ while ! state_done OKE_SETUP; do
411
+ # echo "`date`: Waiting for OKE_SETUP"
412
+ sleep 2
413
+ done
414
+
415
+
395
416
# Collect UI password and create secret
396
417
while ! state_done UI_PASSWORD; do
397
418
while true ; do
@@ -428,16 +449,17 @@ while ! state_done SETUP_VERIFIED; do
428
449
bg_not_done=
429
450
for bg in $bgs ; do
430
451
if state_done $bg ; then
431
- echo " $bg completed"
452
+ echo " $bg has completed"
432
453
else
433
- echo " $bg has not completed "
454
+ # echo "$bg is running "
434
455
NOT_DONE=$(( NOT_DONE+ 1 ))
435
456
bg_not_done=" $bg_not_done $bg "
436
457
fi
437
458
done
438
459
if test " $NOT_DONE " -gt 0; then
439
- echo " Log files are located in $GRABDISH_LOG "
460
+ # echo "Log files are located in $GRABDISH_LOG"
440
461
bgs=$bg_not_done
462
+ echo -ne r" \033[2K\r$bgs still running "
441
463
sleep 10
442
464
else
443
465
state_set_done SETUP_VERIFIED
0 commit comments