diff --git a/configure.sh b/configure.sh index 863a94b6a..c0d3b2501 100755 --- a/configure.sh +++ b/configure.sh @@ -23,11 +23,11 @@ while [[ "$#" > 0 ]]; do case $1 in #; Know-How : In Openshift 3, configure a CakePhp-Mysql-persistent docker image. Set automatic deployment with _100%_ unavailability #; If it starts a build, it automatically scales deployments down to zero, and deploys and scales up when it's finished to build. #; Be sure that lib/Cake/Console/cake test app and Health checks should return gracefullly, or the pods get terminated after a short time. - #; [[-d|--mig-database] [-uyiohn]] argument fixes up : Error: Database connection "Mysql" is missing, or could not be created. + #; [[-d|--mig-database] [-u]] argument fixes up : Error: Database connection "Mysql" is missing, or could not be created. shift - args=("$*") - [[ $openshift ]] && args="${args} --openshift" - shell_prompt "./migrate-database.sh ${args}" "${cyan}Step 3. Migrate database\n${nc}" '-Y' + args="" + [[ $openshift ]] && [[ $(args="--openshift") ]] + shell_prompt "./migrate-database.sh $* ${args}" "${cyan}Step 3. Migrate database\n${nc}" '-Y' break;; -[sS]*|-[pP]*|-[fF]*) #; void source script known args diff --git a/migrate-database.sh b/migrate-database.sh index adcfaed82..d8826f4fd 100755 --- a/migrate-database.sh +++ b/migrate-database.sh @@ -26,7 +26,7 @@ else fi dbfile=database.cms.php fix_socket="-N" -config_app_checked="-N" +config_app_checked="" update_checked=0 import_identities=0 identities=app/Config/database.sql @@ -34,7 +34,7 @@ saved=("$*") while [[ "$#" > 0 ]]; do case $1 in -[uU]* ) update_checked=1 - fix_socket="-Y" + [[ $openshift ]] || fix_socket="-Y" ;; -[yY]* ) # set anything to validate, or none is equal to "-N" @@ -43,11 +43,12 @@ while [[ "$#" > 0 ]]; do case $1 in -[nN]* ) fix_socket="-N" dbfile="" + config_app_checked="-N" ;; -[iI]* ) - fix_socket="-Y" - [ ! -z $DATABASE_NAME ] && [ ! -z $DATABASE_USER ] && [ ! -z $DATABASE_PASSWORD ] && [ ! -z $MYSQL_SERVICE_HOST ] || (echo -e "${red}ERROR : Missing Database VARIABLES.${nc}\n" && export -p | grep "DATABASE\|MYSQL"); - [ ! -z $TEST_DATABASE_NAME ] && [ ! -z $TEST_DATABASE_USER ] && [ ! -z $TEST_DATABASE_PASSWORD ] && [ ! -z $TEST_MYSQL_SERVICE_HOST ] || (echo -e "${red}ERROR : Missing Test Database VARIABLES.${nc}\n" && export -p | grep "TEST_DATABASE\|MYSQL"); + [[ $openshift ]] || [[ $(fix_socket="-Y") ]] + [ ! -z $DATABASE_NAME ] && [ ! -z $DATABASE_USER ] && [ ! -z $DATABASE_PASSWORD ] && [ ! -z $MYSQL_SERVICE_HOST ] || (echo -e "${red}ERROR : Missing Database VARIABLES.${nc}\n" && export -p | grep " DATABASE\| MYSQL"); + [ ! -z $TEST_DATABASE_NAME ] && [ ! -z $TEST_DATABASE_USER ] && [ ! -z $TEST_DATABASE_PASSWORD ] && [ ! -z $TEST_MYSQL_SERVICE_HOST ] || (echo -e "${red}ERROR : Missing Test Database VARIABLES.${nc}\n" && export -p | grep "TEST_DATABASE\|TEST_MYSQL"); if [[ -f $identities ]]; then source ./Scripts/cp_bkp_old.sh . $identities ${identities}.old; fi echo -e "\r${red}WARNING: You will modify SQL ${DATABASE_USER} password !${nc}" && parse_sql_password "$2" "set_DATABASE_PASSWORD" "new ${DATABASE_USER}" && @@ -71,9 +72,9 @@ select * from user where user = '${TEST_DATABASE_USER}';\r grant all on ${TEST_DATABASE_NAME}.* to '${TEST_DATABASE_USER}'@'${TEST_MYSQL_SERVICE_HOST}';\r " > $identities import_identities=1 - ;; + break;; -[vV]*|--verbose ) - cat $identities + [ -f $identities ] && cat $identities echo -e " ${red} ///// MySQL HOWTO: connect to the database${nc} @@ -89,7 +90,7 @@ grant all on ${TEST_DATABASE_NAME}.* to '${TEST_DATABASE_USER}'@'${TEST_MYSQL_SE These SQL statements initializes the database, replaced with current ${orange}environment variables${nc} : " # Reset passed args (shift reset) - echo "Passed params : $0 ${saved}";; + echo "Passed params : $0 ${saved}";; -[hH]*|--help ) echo "Usage: $0 [-u] [-y|n] [-o] [-p|--sql-password=] [-t,--test-sql-password=] [-i] [-p|--new-sql-password=] [-t,--new-test-sql-password=] -u @@ -101,7 +102,7 @@ grant all on ${TEST_DATABASE_NAME}.* to '${TEST_DATABASE_USER}'@'${TEST_MYSQL_SE -i -p= -t= Import SQL identities -o, --openshift - Resets ${dbfile}, keep socket and update the database (should be used with -i) + Resets ${dbfile}, keep socket and update the database -p, --sql-password= Exports DATABASE_PASSWORD -t,--test-sql-password= @@ -132,13 +133,13 @@ shift; done # configure user application database and eventually alter user database access [ -z $dbfile ] && [ $fix_socket == "-N" ] && [ -f app/Config/database.php ] || config_app_checked="-Y" shell_prompt "./Scripts/config_app_database.sh ${dbfile} ${fix_socket}" "${cyan}Setup ${dbfile} connection and socket\n${nc}" $config_app_checked -if [[ (-f $identities) && ($import_identities -eq 1) ]]; then +if [[ (-f $identities) && $import_identities ]]; then echo -e "Importing the mysql ${cyan}${DATABASE_USER}${nc} and ${cyan}${TEST_DATABASE_USER}${nc} users SQL identities..." echo "source ${identities}" | mysql -u $DATABASE_USER --password=$DATABASE_PASSWORD export DATABASE_PASSWORD=$set_DATABASE_PASSWORD export TEST_DATABASE_PASSWORD=$set_TEST_DATABASE_PASSWORD fi -if [ $update_checked == 1 ]; then +if [[ $update_checked ]]; then #; update plugins and dependencies source ./Scripts/composer.sh "-o" #; cakephp shell