55# Fail on error
66set -e
77
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+
820# Check home is set
921if test -z " $LAB_HOME " ; then
1022 echo " ERROR: This script requires LAB_HOME to be set"
@@ -45,7 +57,7 @@ while ! state_done USER_OCID; do
4557 USER_OCID=$TEST_USER_OCID
4658 fi
4759 # 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
4961 state_set USER_OCID " $USER_OCID "
5062 else
5163 echo " That user OCID could not be validated"
93105
94106# Double check and then set the region
95107while ! state_done REGION; do
96- if test $( state_get RUN_TYPE) -eq 1; then
108+ if test " $( state_get RUN_TYPE) " -eq 1; then
97109 HOME_REGION=$( oci iam region-subscription list --query ' data[?"is-home-region"]."region-name" | join(' \' ' ' \' ' , @)' --raw-output)
98110 state_set HOME_REGION " $HOME_REGION "
99111 fi
103115
104116# Create the compartment
105117while ! 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
107119 echo " Resources will be created in a new compartment named $( state_get RUN_NAME) "
108120 export OCI_CLI_PROFILE=$( state_get HOME_REGION)
109121 LAB_DESCRIPTION=" Simplify Event-driven Apps with TxEventQ in Oracle Database (with Kafka interoperability)"
@@ -176,7 +188,7 @@ while ! state_done NAMESPACE; do
176188done
177189
178190# Install GraalVM
179- GRAALVM_VERSION=" 22.1 .0"
191+ GRAALVM_VERSION=" 22.2 .0"
180192if ! state_get GRAALVM_INSTALLED; then
181193 if ps -ef | grep " $LAB_HOME /cloud-setup/java/graalvm-install.sh" | grep -v grep; then
182194 echo " $LAB_HOME /cloud-setup/java/graalvm-install.sh is already running"
@@ -186,17 +198,6 @@ if ! state_get GRAALVM_INSTALLED; then
186198 fi
187199fi
188200
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-
200201# run oracle_db_setup.sh in background
201202if ! state_get DB_SETUP; then
202203 if ps -ef | grep " $LAB_HOME /cloud-setup/database/oracle_db_setup.sh" | grep -v grep; then
211212# Collect DB password
212213if ! state_done DB_PASSWORD; then
213214 echo
215+ echo ' Enter the password to be used for the lab database.'
214216 echo ' Database passwords must be 12 to 30 characters and contain at least one uppercase letter,'
215217 echo ' one lowercase letter, and one number. The password cannot contain the double quote (")'
216218 echo ' character or the word "admin".'
217219 echo
218220
219221 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
226236 echo
227237 break
228238 else
229- echo " Invalid Password, please retry"
239+ echo " $msg "
240+ echo " You have entered invalid passwords. Please, try again.."
241+ echo
230242 fi
231243 done
232244 BASE64_DB_PASSWORD=$( echo -n " $PW " | base64)
0 commit comments