5
5
# Fail on error
6
6
set -e
7
7
8
+ function db_password_valid() {
9
+ local password=$1
10
+ (( ${# password} >= 12 )) || echo ' Error: Too short'
11
+ (( ${# password} <= 30 )) || echo ' Error: Too long'
12
+ [[ $password == * [[:digit:]]* ]] || echo ' Error: Does not contain a digit'
13
+ [[ $password == * [[:lower:]]* ]] || echo ' Error: Does not contain a lower case letter'
14
+ [[ $password == * [[:upper:]]* ]] || echo ' Error: Does not contain an upper case letter'
15
+ [[ $password != * ' "' * ]] || echo ' Error: Cannot contain the double quote (") character'
16
+ [[ $( echo " $password " | tr ' [:lower:]' ' [:upper:]' ) != * ' ADMIN' * ]] || echo ' Error: Cannot contain the word "admin".'
17
+ }
18
+
19
+
8
20
# Check home is set
9
21
if test -z " $LAB_HOME " ; then
10
22
echo " ERROR: This script requires LAB_HOME to be set"
@@ -45,7 +57,7 @@ while ! state_done USER_OCID; do
45
57
USER_OCID=$TEST_USER_OCID
46
58
fi
47
59
# Validate
48
- if test " " $( oci iam user get --user-id " $USER_OCID " --query ' data."lifecycle-state"' --raw-output 2> " ${LAB_LOG} " /user_ocid_err) == ' ACTIVE' ; then
60
+ if test $( oci iam user get --user-id " $USER_OCID " --query ' data."lifecycle-state"' --raw-output 2> " ${LAB_LOG} " /user_ocid_err) == ' ACTIVE' ; then
49
61
state_set USER_OCID " $USER_OCID "
50
62
else
51
63
echo " That user OCID could not be validated"
93
105
94
106
# Double check and then set the region
95
107
while ! state_done REGION; do
96
- if test $( state_get RUN_TYPE) -eq 1; then
108
+ if test " $( state_get RUN_TYPE) " -eq 1; then
97
109
HOME_REGION=$( oci iam region-subscription list --query ' data[?"is-home-region"]."region-name" | join(' \' ' ' \' ' , @)' --raw-output)
98
110
state_set HOME_REGION " $HOME_REGION "
99
111
fi
103
115
104
116
# Create the compartment
105
117
while ! state_done COMPARTMENT_OCID; do
106
- if test $( state_get RUN_TYPE) -ne 3; then
118
+ if test " $( state_get RUN_TYPE) " -ne 3; then
107
119
echo " Resources will be created in a new compartment named $( state_get RUN_NAME) "
108
120
export OCI_CLI_PROFILE=$( state_get HOME_REGION)
109
121
LAB_DESCRIPTION=" Simplify Event-driven Apps with TxEventQ in Oracle Database (with Kafka interoperability)"
@@ -176,7 +188,7 @@ while ! state_done NAMESPACE; do
176
188
done
177
189
178
190
# Install GraalVM
179
- GRAALVM_VERSION=" 22.1 .0"
191
+ GRAALVM_VERSION=" 22.2 .0"
180
192
if ! state_get GRAALVM_INSTALLED; then
181
193
if ps -ef | grep " $LAB_HOME /cloud-setup/java/graalvm-install.sh" | grep -v grep; then
182
194
echo " $LAB_HOME /cloud-setup/java/graalvm-install.sh is already running"
@@ -186,17 +198,6 @@ if ! state_get GRAALVM_INSTALLED; then
186
198
fi
187
199
fi
188
200
189
- if ! state_done CONTAINER_ENG_SETUP; then
190
- echo " $( date) : Installing GraalVM CE Java 11 Image"
191
- docker pull ghcr.io/graalvm/graalvm-ce:ol8-java11 --quiet
192
- # echo "$(date): Create Containers Network"
193
- # LAB_KAFKA_NETWORK="$(state_get RUN_NAME)_net"
194
- # docker network create "${LAB_KAFKA_NETWORK}"
195
- # state_set LAB_KAFKA_NETWORK "$LAB_KAFKA_NETWORK"
196
- state_set_done CONTAINER_ENG_SETUP
197
- echo
198
- fi
199
-
200
201
# run oracle_db_setup.sh in background
201
202
if ! state_get DB_SETUP; then
202
203
if ps -ef | grep " $LAB_HOME /cloud-setup/database/oracle_db_setup.sh" | grep -v grep; then
211
212
# Collect DB password
212
213
if ! state_done DB_PASSWORD; then
213
214
echo
215
+ echo ' Enter the password to be used for the lab database.'
214
216
echo ' Database passwords must be 12 to 30 characters and contain at least one uppercase letter,'
215
217
echo ' one lowercase letter, and one number. The password cannot contain the double quote (")'
216
218
echo ' character or the word "admin".'
217
219
echo
218
220
219
221
while true ; do
220
- if test -z " $TEST_DB_PASSWORD " ; then
221
- read -s -r -p " Enter the password to be used for the lab database: " PW
222
- else
223
- PW=" $TEST_DB_PASSWORD "
224
- fi
225
- if [[ ${# PW} -ge 12 && ${# PW} -le 30 && " $PW " =~ [A-Z] && " $PW " =~ [a-z] && " $PW " =~ [0-9] && " $PW " != * admin* && " $PW " != * ' "' * ]]; then
222
+ # read -s -r -p "Enter the password to be used for the lab database: " PW
223
+ read -s -r -p " Please enter a password: " PW
224
+ echo " ***********"
225
+ read -s -r -p " Retype a password: " second
226
+ echo " ***********"
227
+
228
+ if [ " $PW " != " $second " ]; then
229
+ echo " You have entered different passwords. Please, try again.."
230
+ echo
231
+ continue
232
+ fi
233
+
234
+ msg=$( db_password_valid " $PW " ) ;
235
+ if [[ $msg != * ' Error' * ]] ; then
226
236
echo
227
237
break
228
238
else
229
- echo " Invalid Password, please retry"
239
+ echo " $msg "
240
+ echo " You have entered invalid passwords. Please, try again.."
241
+ echo
230
242
fi
231
243
done
232
244
BASE64_DB_PASSWORD=$( echo -n " $PW " | base64)
0 commit comments