From ee9289b2abbb5ba798192665c0f128a62d39aaab Mon Sep 17 00:00:00 2001 From: sumudu-sahan Date: Mon, 16 May 2022 14:22:41 +0530 Subject: [PATCH] Optimized the script. Made optional for base pack file path and connector path --- APIM_DEPLOYER_LINUX.sh | 218 ++++++++++++++++++++++++++-------------- APIM_DEPLOYER_MAC.sh | 222 ++++++++++++++++++++++++++--------------- 2 files changed, 284 insertions(+), 156 deletions(-) diff --git a/APIM_DEPLOYER_LINUX.sh b/APIM_DEPLOYER_LINUX.sh index 216d423..bba8f0f 100644 --- a/APIM_DEPLOYER_LINUX.sh +++ b/APIM_DEPLOYER_LINUX.sh @@ -2,6 +2,7 @@ pathToBasePack="" zipFilename="" extractedPackDirName="" +APIM_VERSION="4.0.0" #MySQL Connector path and the file below pathToMySQLConnectorFile="" @@ -31,7 +32,7 @@ LOG_STATEMENT="" timestamp="" printVersion(){ - printf "V1.0.0\n" + printf "V1.1.0\n" } printUsage(){ @@ -43,17 +44,18 @@ printUsage(){ echo "-d => Parse the deployment pattern here" echo "Available patterns\n * $DEPLOYMENT_GWCP\n * $DEPLOYMENT_FULL" - echo "-f => Base pack location path" + echo "-f => Base pack location path (Optional)" echo "-z => ZIP file name of the APIM pack (Eg: wso2am-4.0.0.zip)" echo "-b => Extracted directory name of the pack. You can take this name inside the ZIP file. (Eg: wso2am-4.0.0)" echo "-r => Root user name of the MySQL server" echo "-p => Root user password of the MySQL server" - echo "-c => Path of the MySQL JDBC connector Jar" + echo "-c => Path of the MySQL JDBC connector Jar (Optional)" echo "-a => APIM database name" echo "-s => SHARED database name" - echo "-u => Update level that needs to update the pack. (optional)" + echo "-u => Update level that needs to update the pack. (Optional)" - echo "Eg: \n sh APIM_DEPLOYER_.sh -f /home/sumudu/.wum3/products/wso2am/4.0.0/wso2am-4.0.0.zip -z wso2am-4.0.0.zip -b wso2am-4.0.0 -d FULL -r root -p PASSWORD -c /home/sumudu/.wum3/products/wso2am/mysql-connector-java-8.0.27.jar -a TEST_APIM_DB -s TEST_SHARED_DB -u 91" + echo "Eg: \n sh APIM_DEPLOYER_.sh -f /home/sumudu/.wum3/products/wso2am/$APIM_VERSION/wso2am-4.0.0.zip -z wso2am-4.0.0.zip -b wso2am-4.0.0 -d FULL -r root -p PASSWORD -c /home/sumudu/.wum3/products/wso2am/mysql-connector-java-8.0.27.jar -a TEST_APIM_DB -s TEST_SHARED_DB -u 91" + echo "Eg: \n sh APIM_DEPLOYER_.sh -z wso2am-4.0.0.zip -b wso2am-4.0.0 -d FULL -r root -p PASSWORD -a TEST_APIM_DB -s TEST_SHARED_DB -u 91" } for var in "$@" @@ -119,10 +121,10 @@ checkTheUpdateFlagAndUpdate(){ LOG_STATEMENT="Starting to update the API Manager pack to level: $UPDATE_LEVEL\n" printINFOLog - rm -rf ../../distributed_deployment/0_gw/wso2am-4.0.0/bin/wso2update_linux - cp wso2update_linux ../../distributed_deployment/0_gw/wso2am-4.0.0/bin + rm -rf ../../distributed_deployment/0_gw/$extractedPackDirName/bin/wso2update_linux + cp wso2update_linux ../../distributed_deployment/0_gw/$extractedPackDirName/bin - cd ../../distributed_deployment/0_gw/wso2am-4.0.0/bin + cd ../../distributed_deployment/0_gw/$extractedPackDirName/bin ./wso2update_linux --no-backup --level $UPDATE_LEVEL LOG_STATEMENT="Updated the API Manager pack to level: $UPDATE_LEVEL\n" @@ -150,25 +152,65 @@ copyTheBasePackToDirs(){ LOG_STATEMENT="Created the directory structure\n" printINFOLog - - LOG_STATEMENT="Copying the ZIP pack to 0_gw directory\n" - printINFOLog - cp $pathToBasePack 0_gw - LOG_STATEMENT="Copied the ZIP pack to 0_gw directory\n" - printINFOLog cd 0_gw - extractTheBasePack + + if [ -z "$pathToBasePack" ] + then + downloadAPIMPack + else + LOG_STATEMENT="Copying the ZIP pack to 0_gw directory\n" + printINFOLog + cp $pathToBasePack . + LOG_STATEMENT="Copied the ZIP pack to 0_gw directory\n" + printINFOLog + extractTheBasePack + removeTheCopiedZip + fi checkTheUpdateFlagAndUpdate } -copyTheDBMSConnector(){ - LOG_STATEMENT="Copying the DBMS connector\n" +removeTheCopiedZip(){ + LOG_STATEMENT="Removing the copied ZIP pack inside the 0_gw directory\n" + printINFOLog + rm -rf $zipFilename + LOG_STATEMENT="Removed the copied ZIP pack inside the 0_gw directory\n" printINFOLog +} + +copyTheDBMSConnector(){ cd ../../ + + if [ -z "$pathToMySQLConnectorFile" ] + then + LOG_STATEMENT="JDBC connector path is not defined. Hence, the script will download the JDBC connector. For that, you need to parse the connector version (hit enter to download the default JDBC connector - 8.0.27)\n\n" + printWARNLog + read -p "Connector Version (Eg: 8.0.27): " connector_version + if [ -z "$connector_version" ] + then + LOG_STATEMENT="JDBC connector version is not defined. Hence downloading the default MySQL JDBC connector (v8.0.27)\n\n" + printWARNLog + connector_version="8.0.27" + wget https://repo1.maven.org/maven2/mysql/mysql-connector-java/${connector_version}/mysql-connector-java-${connector_version}.jar + LOG_STATEMENT="Downloaded the mySQL JDBC connector $connector_version Jar file\n" + printINFOLog + pathToMySQLConnectorFile="mysql-connector-java-${connector_version}.jar" + else + LOG_STATEMENT="Downloading the mySQL JDBC connector $connector_version Jar file\n" + printINFOLog + wget https://repo1.maven.org/maven2/mysql/mysql-connector-java/${connector_version}/mysql-connector-java-${connector_version}.jar + LOG_STATEMENT="Downloaded the mySQL JDBC connector $connector_version Jar file\n" + printINFOLog + pathToMySQLConnectorFile="mysql-connector-java-${connector_version}.jar" + fi + fi + + LOG_STATEMENT="Copying the MySQL JDBC connector $pathToMySQLConnectorFile Jar file\n" + printINFOLog cp $pathToMySQLConnectorFile $extractedPackDirName/repository/components/lib - LOG_STATEMENT="Copied the DBMS connector\n" + + LOG_STATEMENT="Copied the MySQL JDBC connector\n" printINFOLog if [ "$deploymentPattern" = "$DEPLOYMENT_GWCP" ] @@ -179,6 +221,37 @@ copyTheDBMSConnector(){ fi } +downloadAPIMPack(){ + LOG_STATEMENT="Starting to download the API Manager $APIM_VERSION pack\n" + printINFOLog + extractedDirectoryName="APIM_PACK" + zipFileNameDownloaded="$extractedDirectoryName.zip" + curl "https://product-dist.wso2.com/products/api-manager/$APIM_VERSION/$zipFilename" -H "authority: product-dist.wso2.com" -H "referer: https://wso2.com/" > $zipFileNameDownloaded + LOG_STATEMENT="Downloaded the API Manager $APIM_VERSION pack\n" + printINFOLog + + #Line 132 only for local tests + #cp -a ../../$zipFileNameDownloaded . + + LOG_STATEMENT="Extracting the downloaded API Manager $APIM_VERSION zip\n" + printINFOLog + unzip $zipFileNameDownloaded + LOG_STATEMENT="Extracted the downloaded API Manager $APIM_VERSION zip\n" + printINFOLog + + LOG_STATEMENT="Moving the extracted content of the API Manager $APIM_VERSION\n" + printINFOLog + mv $extractedDirectoryName/$extractedPackDirName . + LOG_STATEMENT="Moved the extracted content of the API Manager $APIM_VERSION\n" + printINFOLog + + LOG_STATEMENT="Deleting the $extractedDirectoryName directory\n" + printINFOLog + rm -rf $extractedDirectoryName + LOG_STATEMENT="Deleted the $extractedDirectoryName directory\n" + printINFOLog +} + GWCPDeployments(){ LOG_STATEMENT="Copying the extracted content to 1_cp\n" printINFOLog @@ -190,13 +263,13 @@ GWCPDeployments(){ LOG_STATEMENT="Creating the gateway worker profile\n" printINFOLog - sh 0_gw/wso2am-4.0.0/bin/profileSetup.sh -Dprofile=gateway-worker + sh 0_gw/$extractedPackDirName/bin/profileSetup.sh -Dprofile=gateway-worker LOG_STATEMENT="Created the gateway worker profile\n" printINFOLog LOG_STATEMENT="Creating the control plane profile\n" printINFOLog - sh 1_cp/wso2am-4.0.0/bin/profileSetup.sh -Dprofile=control-plane + sh 1_cp/$extractedPackDirName/bin/profileSetup.sh -Dprofile=control-plane LOG_STATEMENT="Created the control plane profile\n" printINFOLog @@ -204,7 +277,7 @@ GWCPDeployments(){ LOG_STATEMENT="Configuring databases by executing scripts\n[APIM_DB] => $APIM_DB_WSO2AM_400\n[SHARED_DB] => $SHARED_DB_WSO2AM_400\nYou need to enter the MySQL root password to continue this step\n" printINFOLog - cd 0_gw/wso2am-4.0.0/dbscripts + cd 0_gw/$extractedPackDirName/dbscripts mysql -u$MYSQL_ROOT_USERNAME -p -e "DROP DATABASE IF EXISTS $APIM_DB_WSO2AM_400; DROP DATABASE IF EXISTS $SHARED_DB_WSO2AM_400; CREATE DATABASE $APIM_DB_WSO2AM_400;CREATE DATABASE $SHARED_DB_WSO2AM_400;USE $APIM_DB_WSO2AM_400;SOURCE apimgt/mysql.sql;USE $SHARED_DB_WSO2AM_400;SOURCE mysql.sql;SHOW TABLES;USE $APIM_DB_WSO2AM_400;SHOW TABLES;" LOG_STATEMENT="Configured databases by executing scripts successfully\n" @@ -212,19 +285,19 @@ GWCPDeployments(){ cd ../../.. - rm -rf 0_gw/wso2am-4.0.0/repository/conf/deployment.toml - rm -rf 1_cp/wso2am-4.0.0/repository/conf/deployment.toml + rm -rf 0_gw/$extractedPackDirName/repository/conf/deployment.toml + rm -rf 1_cp/$extractedPackDirName/repository/conf/deployment.toml cd ../toml_files - cp gateway-worker-2.toml ../distributed_deployment/0_gw/wso2am-4.0.0/repository/conf - cp control-plane-2.toml ../distributed_deployment/1_cp/wso2am-4.0.0/repository/conf + cp gateway-worker-2.toml ../distributed_deployment/0_gw/$extractedPackDirName/repository/conf + cp control-plane-2.toml ../distributed_deployment/1_cp/$extractedPackDirName/repository/conf LOG_STATEMENT="Starting to replacing deployment.toml files in all 2 nodes by taking from the toml_files directory\n" printINFOLog - mv ../distributed_deployment/0_gw/wso2am-4.0.0/repository/conf/gateway-worker-2.toml ../distributed_deployment/0_gw/wso2am-4.0.0/repository/conf/deployment.toml - mv ../distributed_deployment/1_cp/wso2am-4.0.0/repository/conf/control-plane-2.toml ../distributed_deployment/1_cp/wso2am-4.0.0/repository/conf/deployment.toml + mv ../distributed_deployment/0_gw/$extractedPackDirName/repository/conf/gateway-worker-2.toml ../distributed_deployment/0_gw/$extractedPackDirName/repository/conf/deployment.toml + mv ../distributed_deployment/1_cp/$extractedPackDirName/repository/conf/control-plane-2.toml ../distributed_deployment/1_cp/$extractedPackDirName/repository/conf/deployment.toml LOG_STATEMENT="deployment.toml file replacement is success\n" printINFOLog @@ -235,13 +308,13 @@ GWCPDeployments(){ printINFOLog # #FOR MAC OS, - # #sed -i '' "s/MYSQL_ROOT_USERNAME/$MYSQL_ROOT_USERNAME/gi" 0_gw/wso2am-4.0.0/repository/conf/deployment.toml + # #sed -i '' "s/MYSQL_ROOT_USERNAME/$MYSQL_ROOT_USERNAME/gi" 0_gw/$extractedPackDirName/repository/conf/deployment.toml - sed -i "s/MYSQL_ROOT_USERNAME/$MYSQL_ROOT_USERNAME/gi" 0_gw/wso2am-4.0.0/repository/conf/deployment.toml - sed -i "s/MYSQL_ROOT_USERNAME/$MYSQL_ROOT_USERNAME/gi" 1_cp/wso2am-4.0.0/repository/conf/deployment.toml + sed -i "s/MYSQL_ROOT_USERNAME/$MYSQL_ROOT_USERNAME/gi" 0_gw/$extractedPackDirName/repository/conf/deployment.toml + sed -i "s/MYSQL_ROOT_USERNAME/$MYSQL_ROOT_USERNAME/gi" 1_cp/$extractedPackDirName/repository/conf/deployment.toml - sed -i "s/MYSQL_ROOT_PASSWORD/$MYSQL_ROOT_PASSWORD/gi" 0_gw/wso2am-4.0.0/repository/conf/deployment.toml - sed -i "s/MYSQL_ROOT_PASSWORD/$MYSQL_ROOT_PASSWORD/gi" 1_cp/wso2am-4.0.0/repository/conf/deployment.toml + sed -i "s/MYSQL_ROOT_PASSWORD/$MYSQL_ROOT_PASSWORD/gi" 0_gw/$extractedPackDirName/repository/conf/deployment.toml + sed -i "s/MYSQL_ROOT_PASSWORD/$MYSQL_ROOT_PASSWORD/gi" 1_cp/$extractedPackDirName/repository/conf/deployment.toml LOG_STATEMENT="MySQL root username change is completed successfully files\n" printINFOLog @@ -249,8 +322,8 @@ GWCPDeployments(){ LOG_STATEMENT="Starting to change [database.shared_db] database name configurations in deployment.toml files\n" printINFOLog - sed -i "s/SHARED_DB_WSO2AM_400/$SHARED_DB_WSO2AM_400/gi" 0_gw/wso2am-4.0.0/repository/conf/deployment.toml - sed -i "s/SHARED_DB_WSO2AM_400/$SHARED_DB_WSO2AM_400/gi" 1_cp/wso2am-4.0.0/repository/conf/deployment.toml + sed -i "s/SHARED_DB_WSO2AM_400/$SHARED_DB_WSO2AM_400/gi" 0_gw/$extractedPackDirName/repository/conf/deployment.toml + sed -i "s/SHARED_DB_WSO2AM_400/$SHARED_DB_WSO2AM_400/gi" 1_cp/$extractedPackDirName/repository/conf/deployment.toml LOG_STATEMENT="[database.shared_db] database name configurations changes successfully completed\n" printINFOLog @@ -258,7 +331,7 @@ GWCPDeployments(){ LOG_STATEMENT="Starting to change [database.apim_db] database name configurations in deployment.toml files\n" printINFOLog - sed -i "s/APIM_DB_WSO2AM_400/$APIM_DB_WSO2AM_400/gi" 1_cp/wso2am-4.0.0/repository/conf/deployment.toml + sed -i "s/APIM_DB_WSO2AM_400/$APIM_DB_WSO2AM_400/gi" 1_cp/$extractedPackDirName/repository/conf/deployment.toml LOG_STATEMENT="[database.apim_db] database name configurations changes successfully completed\n" printINFOLog @@ -289,26 +362,26 @@ fullDeployment(){ LOG_STATEMENT="Creating the gateway worker profile\n" printINFOLog - sh 0_gw/wso2am-4.0.0/bin/profileSetup.sh -Dprofile=gateway-worker + sh 0_gw/$extractedPackDirName/bin/profileSetup.sh -Dprofile=gateway-worker LOG_STATEMENT="Created the gateway worker profile\n" printINFOLog LOG_STATEMENT="Creating the traffic manager profile\n" printINFOLog - sh 1_tm/wso2am-4.0.0/bin/profileSetup.sh -Dprofile=traffic-manager + sh 1_tm/$extractedPackDirName/bin/profileSetup.sh -Dprofile=traffic-manager LOG_STATEMENT="Created the traffic manager profile\n" printINFOLog LOG_STATEMENT="Creating the control plane profile\n" printINFOLog - sh 2_cp/wso2am-4.0.0/bin/profileSetup.sh -Dprofile=control-plane + sh 2_cp/$extractedPackDirName/bin/profileSetup.sh -Dprofile=control-plane LOG_STATEMENT="Created the control plane profile\n" printINFOLog LOG_STATEMENT="Configuring databases by executing scripts\n[APIM_DB] => $APIM_DB_WSO2AM_400\n[SHARED_DB] => $SHARED_DB_WSO2AM_400\nYou need to enter the MySQL root password to continue this step\n" printINFOLog - cd 0_gw/wso2am-4.0.0/dbscripts + cd 0_gw/$extractedPackDirName/dbscripts mysql -u$MYSQL_ROOT_USERNAME -p -e "DROP DATABASE IF EXISTS $APIM_DB_WSO2AM_400; DROP DATABASE IF EXISTS $SHARED_DB_WSO2AM_400; CREATE DATABASE $APIM_DB_WSO2AM_400;CREATE DATABASE $SHARED_DB_WSO2AM_400;USE $APIM_DB_WSO2AM_400;SOURCE apimgt/mysql.sql;USE $SHARED_DB_WSO2AM_400;SOURCE mysql.sql;SHOW TABLES;USE $APIM_DB_WSO2AM_400;SHOW TABLES;" LOG_STATEMENT="Configured databases by executing scripts successfully\n" @@ -316,22 +389,22 @@ fullDeployment(){ cd ../../.. - rm -rf 0_gw/wso2am-4.0.0/repository/conf/deployment.toml - rm -rf 1_tm/wso2am-4.0.0/repository/conf/deployment.toml - rm -rf 2_cp/wso2am-4.0.0/repository/conf/deployment.toml + rm -rf 0_gw/$extractedPackDirName/repository/conf/deployment.toml + rm -rf 1_tm/$extractedPackDirName/repository/conf/deployment.toml + rm -rf 2_cp/$extractedPackDirName/repository/conf/deployment.toml cd ../toml_files - cp gateway-worker.toml ../distributed_deployment/0_gw/wso2am-4.0.0/repository/conf - cp traffic-manager.toml ../distributed_deployment/1_tm/wso2am-4.0.0/repository/conf - cp control-plane.toml ../distributed_deployment/2_cp/wso2am-4.0.0/repository/conf + cp gateway-worker.toml ../distributed_deployment/0_gw/$extractedPackDirName/repository/conf + cp traffic-manager.toml ../distributed_deployment/1_tm/$extractedPackDirName/repository/conf + cp control-plane.toml ../distributed_deployment/2_cp/$extractedPackDirName/repository/conf LOG_STATEMENT="Starting to replacing deployment.toml files in all 3 nodes by taking from the toml_files directory\n" printINFOLog - mv ../distributed_deployment/0_gw/wso2am-4.0.0/repository/conf/gateway-worker.toml ../distributed_deployment/0_gw/wso2am-4.0.0/repository/conf/deployment.toml - mv ../distributed_deployment/1_tm/wso2am-4.0.0/repository/conf/traffic-manager.toml ../distributed_deployment/1_tm/wso2am-4.0.0/repository/conf/deployment.toml - mv ../distributed_deployment/2_cp/wso2am-4.0.0/repository/conf/control-plane.toml ../distributed_deployment/2_cp/wso2am-4.0.0/repository/conf/deployment.toml + mv ../distributed_deployment/0_gw/$extractedPackDirName/repository/conf/gateway-worker.toml ../distributed_deployment/0_gw/$extractedPackDirName/repository/conf/deployment.toml + mv ../distributed_deployment/1_tm/$extractedPackDirName/repository/conf/traffic-manager.toml ../distributed_deployment/1_tm/$extractedPackDirName/repository/conf/deployment.toml + mv ../distributed_deployment/2_cp/$extractedPackDirName/repository/conf/control-plane.toml ../distributed_deployment/2_cp/$extractedPackDirName/repository/conf/deployment.toml LOG_STATEMENT="deployment.toml file replacement is success\n" printINFOLog @@ -342,15 +415,15 @@ fullDeployment(){ printINFOLog # #FOR MAC OS, - # #sed -i '' "s/MYSQL_ROOT_USERNAME/$MYSQL_ROOT_USERNAME/gi" 0_gw/wso2am-4.0.0/repository/conf/deployment.toml + # #sed -i '' "s/MYSQL_ROOT_USERNAME/$MYSQL_ROOT_USERNAME/gi" 0_gw/$extractedPackDirName/repository/conf/deployment.toml - sed -i "s/MYSQL_ROOT_USERNAME/$MYSQL_ROOT_USERNAME/gi" 0_gw/wso2am-4.0.0/repository/conf/deployment.toml - sed -i "s/MYSQL_ROOT_USERNAME/$MYSQL_ROOT_USERNAME/gi" 1_tm/wso2am-4.0.0/repository/conf/deployment.toml - sed -i "s/MYSQL_ROOT_USERNAME/$MYSQL_ROOT_USERNAME/gi" 2_cp/wso2am-4.0.0/repository/conf/deployment.toml + sed -i "s/MYSQL_ROOT_USERNAME/$MYSQL_ROOT_USERNAME/gi" 0_gw/$extractedPackDirName/repository/conf/deployment.toml + sed -i "s/MYSQL_ROOT_USERNAME/$MYSQL_ROOT_USERNAME/gi" 1_tm/$extractedPackDirName/repository/conf/deployment.toml + sed -i "s/MYSQL_ROOT_USERNAME/$MYSQL_ROOT_USERNAME/gi" 2_cp/$extractedPackDirName/repository/conf/deployment.toml - sed -i "s/MYSQL_ROOT_PASSWORD/$MYSQL_ROOT_PASSWORD/gi" 0_gw/wso2am-4.0.0/repository/conf/deployment.toml - sed -i "s/MYSQL_ROOT_PASSWORD/$MYSQL_ROOT_PASSWORD/gi" 1_tm/wso2am-4.0.0/repository/conf/deployment.toml - sed -i "s/MYSQL_ROOT_PASSWORD/$MYSQL_ROOT_PASSWORD/gi" 2_cp/wso2am-4.0.0/repository/conf/deployment.toml + sed -i "s/MYSQL_ROOT_PASSWORD/$MYSQL_ROOT_PASSWORD/gi" 0_gw/$extractedPackDirName/repository/conf/deployment.toml + sed -i "s/MYSQL_ROOT_PASSWORD/$MYSQL_ROOT_PASSWORD/gi" 1_tm/$extractedPackDirName/repository/conf/deployment.toml + sed -i "s/MYSQL_ROOT_PASSWORD/$MYSQL_ROOT_PASSWORD/gi" 2_cp/$extractedPackDirName/repository/conf/deployment.toml LOG_STATEMENT="MySQL root username change is completed successfully files\n" printINFOLog @@ -358,9 +431,9 @@ fullDeployment(){ LOG_STATEMENT="Starting to change [database.shared_db] database name configurations in deployment.toml files\n" printINFOLog - sed -i "s/SHARED_DB_WSO2AM_400/$SHARED_DB_WSO2AM_400/gi" 0_gw/wso2am-4.0.0/repository/conf/deployment.toml - sed -i "s/SHARED_DB_WSO2AM_400/$SHARED_DB_WSO2AM_400/gi" 1_tm/wso2am-4.0.0/repository/conf/deployment.toml - sed -i "s/SHARED_DB_WSO2AM_400/$SHARED_DB_WSO2AM_400/gi" 2_cp/wso2am-4.0.0/repository/conf/deployment.toml + sed -i "s/SHARED_DB_WSO2AM_400/$SHARED_DB_WSO2AM_400/gi" 0_gw/$extractedPackDirName/repository/conf/deployment.toml + sed -i "s/SHARED_DB_WSO2AM_400/$SHARED_DB_WSO2AM_400/gi" 1_tm/$extractedPackDirName/repository/conf/deployment.toml + sed -i "s/SHARED_DB_WSO2AM_400/$SHARED_DB_WSO2AM_400/gi" 2_cp/$extractedPackDirName/repository/conf/deployment.toml LOG_STATEMENT="[database.shared_db] database name configurations changes successfully completed\n" printINFOLog @@ -368,8 +441,8 @@ fullDeployment(){ LOG_STATEMENT="Starting to change [database.apim_db] database name configurations in deployment.toml files\n" printINFOLog - sed -i "s/APIM_DB_WSO2AM_400/$APIM_DB_WSO2AM_400/gi" 1_tm/wso2am-4.0.0/repository/conf/deployment.toml - sed -i "s/APIM_DB_WSO2AM_400/$APIM_DB_WSO2AM_400/gi" 2_cp/wso2am-4.0.0/repository/conf/deployment.toml + sed -i "s/APIM_DB_WSO2AM_400/$APIM_DB_WSO2AM_400/gi" 1_tm/$extractedPackDirName/repository/conf/deployment.toml + sed -i "s/APIM_DB_WSO2AM_400/$APIM_DB_WSO2AM_400/gi" 2_cp/$extractedPackDirName/repository/conf/deployment.toml LOG_STATEMENT="[database.apim_db] database name configurations changes successfully completed\n" printINFOLog @@ -404,7 +477,7 @@ extractTheBasePack(){ } init(){ - LOG_STATEMENT="Starting the distributed deployment script of the WSO2 API Manager 4.0.0\n" + LOG_STATEMENT="Starting the distributed deployment script of the WSO2 API Manager $APIM_VERSION\n" printINFOLog LOG_STATEMENT="Created by Sumudu Weerasuriya from the Integration CS Team\n" printINFOLog @@ -444,20 +517,6 @@ init(){ exit 1 fi - if [ -z "$pathToBasePack" ] - then - LOG_STATEMENT="Base pack path is not defined\n" - printERRLog - exit 1 - fi - - if [ -z "$pathToMySQLConnectorFile" ] - then - LOG_STATEMENT="JDBC connector path is not defined\n" - printERRLog - exit 1 - fi - if [ -z "$MYSQL_ROOT_USERNAME" ] then LOG_STATEMENT="MySQL root user name is not defined\n" @@ -489,7 +548,7 @@ init(){ LOG_STATEMENT="\n\nDEPLOYMENT DETAILS \n\n* Deployment Pattern: $deploymentPattern \n* Base Pack Path: $pathToBasePack\n* ZIP Name: $zipFilename\n* Update Level: $UPDATE_LEVEL\n* Directory Name Of The Extracted Content: $extractedPackDirName \n\n" printConfigDetail - LOG_STATEMENT="\n\nDATABASE DETAILS \n\n* JDBC Connector File Path: $pathToMySQLConnectorFile \n* ROOT User Name: $MYSQL_ROOT_USERNAME\n* APIM Database Name: $APIM_DB_WSO2AM_400\n* Shared Database Name: $SHARED_DB_WSO2AM_400\n\n" + LOG_STATEMENT="\n\nDATABASE DETAILS \n\n* ROOT User Name: $MYSQL_ROOT_USERNAME\n* APIM Database Name: $APIM_DB_WSO2AM_400\n* Shared Database Name: $SHARED_DB_WSO2AM_400\n\n" printConfigDetail case "$deploymentPattern" in @@ -520,9 +579,14 @@ printERRLog(){ printf "[${timestamp}] ERROR - $LOG_STATEMENT" } +printWARNLog(){ + getSystemTimestamp + printf "[${timestamp}] WARN - $LOG_STATEMENT" +} + printConfigDetail(){ getSystemTimestamp - printf "[${timestamp}] CONFIG_DETAIL - $LOG_STATEMENT" + printf "[${timestamp}] CONFIG_DETAIL \n$LOG_STATEMENT" } init \ No newline at end of file diff --git a/APIM_DEPLOYER_MAC.sh b/APIM_DEPLOYER_MAC.sh index 7441f2c..b4a9f5d 100644 --- a/APIM_DEPLOYER_MAC.sh +++ b/APIM_DEPLOYER_MAC.sh @@ -2,6 +2,7 @@ pathToBasePack="" zipFilename="" extractedPackDirName="" +APIM_VERSION="4.0.0" #MySQL Connector path and the file below pathToMySQLConnectorFile="" @@ -31,7 +32,7 @@ LOG_STATEMENT="" timestamp="" printVersion(){ - printf "V1.0.0\n" + printf "V1.1.0\n" } printUsage(){ @@ -43,17 +44,18 @@ printUsage(){ echo "-d => Parse the deployment pattern here" echo "Available patterns\n * $DEPLOYMENT_GWCP\n * $DEPLOYMENT_FULL" - echo "-f => Base pack location path" + echo "-f => Base pack location path (Optional)" echo "-z => ZIP file name of the APIM pack (Eg: wso2am-4.0.0.zip)" echo "-b => Extracted directory name of the pack. You can take this name inside the ZIP file. (Eg: wso2am-4.0.0)" echo "-r => Root user name of the MySQL server" echo "-p => Root user password of the MySQL server" - echo "-c => Path of the MySQL JDBC connector Jar" + echo "-c => Path of the MySQL JDBC connector Jar (Optional)" echo "-a => APIM database name" echo "-s => SHARED database name" - echo "-u => Update level that needs to update the pack. (optional)" + echo "-u => Update level that needs to update the pack. (Optional)" - echo "Eg: \n sh APIM_DEPLOYER_.sh -f /home/sumudu/.wum3/products/wso2am/4.0.0/wso2am-4.0.0.zip -z wso2am-4.0.0.zip -b wso2am-4.0.0 -d FULL -r root -p PASSWORD -c /home/sumudu/.wum3/products/wso2am/mysql-connector-java-8.0.27.jar -a TEST_APIM_DB -s TEST_SHARED_DB -u 91" + echo "Eg: \n sh APIM_DEPLOYER_.sh -f /home/sumudu/.wum3/products/wso2am/$APIM_VERSION/wso2am-4.0.0.zip -z wso2am-4.0.0.zip -b wso2am-4.0.0 -d FULL -r root -p PASSWORD -c /home/sumudu/.wum3/products/wso2am/mysql-connector-java-8.0.27.jar -a TEST_APIM_DB -s TEST_SHARED_DB -u 91" + echo "Eg: \n sh APIM_DEPLOYER_.sh -z wso2am-4.0.0.zip -b wso2am-4.0.0 -d FULL -r root -p PASSWORD -a TEST_APIM_DB -s TEST_SHARED_DB -u 91" } for var in "$@" @@ -109,7 +111,7 @@ checkTheUpdateFlagAndUpdate(){ printINFOLog cd ../../U2_CLIENT/bin - ./wso2update_darwin_original + ./wso2update_linux_original LOG_STATEMENT="Updated the Update 2.0- client\n" printINFOLog @@ -117,11 +119,11 @@ checkTheUpdateFlagAndUpdate(){ LOG_STATEMENT="Starting to update the API Manager pack to level: $UPDATE_LEVEL\n" printINFOLog - rm -rf ../../distributed_deployment/0_gw/wso2am-4.0.0/bin/wso2update_darwin - cp wso2update_darwin ../../distributed_deployment/0_gw/wso2am-4.0.0/bin + rm -rf ../../distributed_deployment/0_gw/$extractedPackDirName/bin/wso2update_linux + cp wso2update_linux ../../distributed_deployment/0_gw/$extractedPackDirName/bin - cd ../../distributed_deployment/0_gw/wso2am-4.0.0/bin - ./wso2update_darwin --no-backup --level $UPDATE_LEVEL + cd ../../distributed_deployment/0_gw/$extractedPackDirName/bin + ./wso2update_linux --no-backup --level $UPDATE_LEVEL LOG_STATEMENT="Updated the API Manager pack to level: $UPDATE_LEVEL\n" printINFOLog @@ -148,25 +150,65 @@ copyTheBasePackToDirs(){ LOG_STATEMENT="Created the directory structure\n" printINFOLog - - LOG_STATEMENT="Copying the ZIP pack to 0_gw directory\n" - printINFOLog - cp $pathToBasePack 0_gw - LOG_STATEMENT="Copied the ZIP pack to 0_gw directory\n" - printINFOLog cd 0_gw - extractTheBasePack + + if [ -z "$pathToBasePack" ] + then + downloadAPIMPack + else + LOG_STATEMENT="Copying the ZIP pack to 0_gw directory\n" + printINFOLog + cp $pathToBasePack . + LOG_STATEMENT="Copied the ZIP pack to 0_gw directory\n" + printINFOLog + extractTheBasePack + removeTheCopiedZip + fi checkTheUpdateFlagAndUpdate } -copyTheDBMSConnector(){ - LOG_STATEMENT="Copying the DBMS connector\n" +removeTheCopiedZip(){ + LOG_STATEMENT="Removing the copied ZIP pack inside the 0_gw directory\n" + printINFOLog + rm -rf $zipFilename + LOG_STATEMENT="Removed the copied ZIP pack inside the 0_gw directory\n" printINFOLog +} + +copyTheDBMSConnector(){ cd ../../ + + if [ -z "$pathToMySQLConnectorFile" ] + then + LOG_STATEMENT="JDBC connector path is not defined. Hence, the script will download the JDBC connector. For that, you need to parse the connector version (hit enter to download the default JDBC connector - 8.0.27)\n\n" + printWARNLog + read -p "Connector Version (Eg: 8.0.27): " connector_version + if [ -z "$connector_version" ] + then + LOG_STATEMENT="JDBC connector version is not defined. Hence downloading the default MySQL JDBC connector (v8.0.27)\n\n" + printWARNLog + connector_version="8.0.27" + wget https://repo1.maven.org/maven2/mysql/mysql-connector-java/${connector_version}/mysql-connector-java-${connector_version}.jar + LOG_STATEMENT="Downloaded the mySQL JDBC connector $connector_version Jar file\n" + printINFOLog + pathToMySQLConnectorFile="mysql-connector-java-${connector_version}.jar" + else + LOG_STATEMENT="Downloading the mySQL JDBC connector $connector_version Jar file\n" + printINFOLog + wget https://repo1.maven.org/maven2/mysql/mysql-connector-java/${connector_version}/mysql-connector-java-${connector_version}.jar + LOG_STATEMENT="Downloaded the mySQL JDBC connector $connector_version Jar file\n" + printINFOLog + pathToMySQLConnectorFile="mysql-connector-java-${connector_version}.jar" + fi + fi + + LOG_STATEMENT="Copying the MySQL JDBC connector $pathToMySQLConnectorFile Jar file\n" + printINFOLog cp $pathToMySQLConnectorFile $extractedPackDirName/repository/components/lib - LOG_STATEMENT="Copied the DBMS connector\n" + + LOG_STATEMENT="Copied the MySQL JDBC connector\n" printINFOLog if [ "$deploymentPattern" = "$DEPLOYMENT_GWCP" ] @@ -177,6 +219,37 @@ copyTheDBMSConnector(){ fi } +downloadAPIMPack(){ + LOG_STATEMENT="Starting to download the API Manager $APIM_VERSION pack\n" + printINFOLog + extractedDirectoryName="APIM_PACK" + zipFileNameDownloaded="$extractedDirectoryName.zip" + curl "https://product-dist.wso2.com/products/api-manager/$APIM_VERSION/$zipFilename" -H "authority: product-dist.wso2.com" -H "referer: https://wso2.com/" > $zipFileNameDownloaded + LOG_STATEMENT="Downloaded the API Manager $APIM_VERSION pack\n" + printINFOLog + + #Line 132 only for local tests + #cp -a ../../$zipFileNameDownloaded . + + LOG_STATEMENT="Extracting the downloaded API Manager $APIM_VERSION zip\n" + printINFOLog + unzip $zipFileNameDownloaded + LOG_STATEMENT="Extracted the downloaded API Manager $APIM_VERSION zip\n" + printINFOLog + + LOG_STATEMENT="Moving the extracted content of the API Manager $APIM_VERSION\n" + printINFOLog + mv $extractedDirectoryName/$extractedPackDirName . + LOG_STATEMENT="Moved the extracted content of the API Manager $APIM_VERSION\n" + printINFOLog + + LOG_STATEMENT="Deleting the $extractedDirectoryName directory\n" + printINFOLog + rm -rf $extractedDirectoryName + LOG_STATEMENT="Deleted the $extractedDirectoryName directory\n" + printINFOLog +} + GWCPDeployments(){ LOG_STATEMENT="Copying the extracted content to 1_cp\n" printINFOLog @@ -188,13 +261,13 @@ GWCPDeployments(){ LOG_STATEMENT="Creating the gateway worker profile\n" printINFOLog - sh 0_gw/wso2am-4.0.0/bin/profileSetup.sh -Dprofile=gateway-worker + sh 0_gw/$extractedPackDirName/bin/profileSetup.sh -Dprofile=gateway-worker LOG_STATEMENT="Created the gateway worker profile\n" printINFOLog LOG_STATEMENT="Creating the control plane profile\n" printINFOLog - sh 1_cp/wso2am-4.0.0/bin/profileSetup.sh -Dprofile=control-plane + sh 1_cp/$extractedPackDirName/bin/profileSetup.sh -Dprofile=control-plane LOG_STATEMENT="Created the control plane profile\n" printINFOLog @@ -202,7 +275,7 @@ GWCPDeployments(){ LOG_STATEMENT="Configuring databases by executing scripts\n[APIM_DB] => $APIM_DB_WSO2AM_400\n[SHARED_DB] => $SHARED_DB_WSO2AM_400\nYou need to enter the MySQL root password to continue this step\n" printINFOLog - cd 0_gw/wso2am-4.0.0/dbscripts + cd 0_gw/$extractedPackDirName/dbscripts mysql -u$MYSQL_ROOT_USERNAME -p -e "DROP DATABASE IF EXISTS $APIM_DB_WSO2AM_400; DROP DATABASE IF EXISTS $SHARED_DB_WSO2AM_400; CREATE DATABASE $APIM_DB_WSO2AM_400;CREATE DATABASE $SHARED_DB_WSO2AM_400;USE $APIM_DB_WSO2AM_400;SOURCE apimgt/mysql.sql;USE $SHARED_DB_WSO2AM_400;SOURCE mysql.sql;SHOW TABLES;USE $APIM_DB_WSO2AM_400;SHOW TABLES;" LOG_STATEMENT="Configured databases by executing scripts successfully\n" @@ -210,19 +283,19 @@ GWCPDeployments(){ cd ../../.. - rm -rf 0_gw/wso2am-4.0.0/repository/conf/deployment.toml - rm -rf 1_cp/wso2am-4.0.0/repository/conf/deployment.toml + rm -rf 0_gw/$extractedPackDirName/repository/conf/deployment.toml + rm -rf 1_cp/$extractedPackDirName/repository/conf/deployment.toml cd ../toml_files - cp gateway-worker-2.toml ../distributed_deployment/0_gw/wso2am-4.0.0/repository/conf - cp control-plane-2.toml ../distributed_deployment/1_cp/wso2am-4.0.0/repository/conf + cp gateway-worker-2.toml ../distributed_deployment/0_gw/$extractedPackDirName/repository/conf + cp control-plane-2.toml ../distributed_deployment/1_cp/$extractedPackDirName/repository/conf LOG_STATEMENT="Starting to replacing deployment.toml files in all 2 nodes by taking from the toml_files directory\n" printINFOLog - mv ../distributed_deployment/0_gw/wso2am-4.0.0/repository/conf/gateway-worker-2.toml ../distributed_deployment/0_gw/wso2am-4.0.0/repository/conf/deployment.toml - mv ../distributed_deployment/1_cp/wso2am-4.0.0/repository/conf/control-plane-2.toml ../distributed_deployment/1_cp/wso2am-4.0.0/repository/conf/deployment.toml + mv ../distributed_deployment/0_gw/$extractedPackDirName/repository/conf/gateway-worker-2.toml ../distributed_deployment/0_gw/$extractedPackDirName/repository/conf/deployment.toml + mv ../distributed_deployment/1_cp/$extractedPackDirName/repository/conf/control-plane-2.toml ../distributed_deployment/1_cp/$extractedPackDirName/repository/conf/deployment.toml LOG_STATEMENT="deployment.toml file replacement is success\n" printINFOLog @@ -233,13 +306,13 @@ GWCPDeployments(){ printINFOLog # #FOR MAC OS, - # #sed -i '' "s/MYSQL_ROOT_USERNAME/$MYSQL_ROOT_USERNAME/gi" 0_gw/wso2am-4.0.0/repository/conf/deployment.toml + # #sed -i '' "s/MYSQL_ROOT_USERNAME/$MYSQL_ROOT_USERNAME/gi" 0_gw/$extractedPackDirName/repository/conf/deployment.toml - sed -i '' "s/MYSQL_ROOT_USERNAME/$MYSQL_ROOT_USERNAME/gi" 0_gw/wso2am-4.0.0/repository/conf/deployment.toml - sed -i '' "s/MYSQL_ROOT_USERNAME/$MYSQL_ROOT_USERNAME/gi" 1_cp/wso2am-4.0.0/repository/conf/deployment.toml + sed -i '' "s/MYSQL_ROOT_USERNAME/$MYSQL_ROOT_USERNAME/gi" 0_gw/$extractedPackDirName/repository/conf/deployment.toml + sed -i '' "s/MYSQL_ROOT_USERNAME/$MYSQL_ROOT_USERNAME/gi" 1_cp/$extractedPackDirName/repository/conf/deployment.toml - sed -i '' "s/MYSQL_ROOT_PASSWORD/$MYSQL_ROOT_PASSWORD/gi" 0_gw/wso2am-4.0.0/repository/conf/deployment.toml - sed -i '' "s/MYSQL_ROOT_PASSWORD/$MYSQL_ROOT_PASSWORD/gi" 1_cp/wso2am-4.0.0/repository/conf/deployment.toml + sed -i '' "s/MYSQL_ROOT_PASSWORD/$MYSQL_ROOT_PASSWORD/gi" 0_gw/$extractedPackDirName/repository/conf/deployment.toml + sed -i '' "s/MYSQL_ROOT_PASSWORD/$MYSQL_ROOT_PASSWORD/gi" 1_cp/$extractedPackDirName/repository/conf/deployment.toml LOG_STATEMENT="MySQL root username change is completed successfully files\n" printINFOLog @@ -247,8 +320,8 @@ GWCPDeployments(){ LOG_STATEMENT="Starting to change [database.shared_db] database name configurations in deployment.toml files\n" printINFOLog - sed -i '' "s/SHARED_DB_WSO2AM_400/$SHARED_DB_WSO2AM_400/gi" 0_gw/wso2am-4.0.0/repository/conf/deployment.toml - sed -i '' "s/SHARED_DB_WSO2AM_400/$SHARED_DB_WSO2AM_400/gi" 1_cp/wso2am-4.0.0/repository/conf/deployment.toml + sed -i '' "s/SHARED_DB_WSO2AM_400/$SHARED_DB_WSO2AM_400/gi" 0_gw/$extractedPackDirName/repository/conf/deployment.toml + sed -i '' "s/SHARED_DB_WSO2AM_400/$SHARED_DB_WSO2AM_400/gi" 1_cp/$extractedPackDirName/repository/conf/deployment.toml LOG_STATEMENT="[database.shared_db] database name configurations changes successfully completed\n" printINFOLog @@ -256,7 +329,7 @@ GWCPDeployments(){ LOG_STATEMENT="Starting to change [database.apim_db] database name configurations in deployment.toml files\n" printINFOLog - sed -i '' "s/APIM_DB_WSO2AM_400/$APIM_DB_WSO2AM_400/gi" 1_cp/wso2am-4.0.0/repository/conf/deployment.toml + sed -i '' "s/APIM_DB_WSO2AM_400/$APIM_DB_WSO2AM_400/gi" 1_cp/$extractedPackDirName/repository/conf/deployment.toml LOG_STATEMENT="[database.apim_db] database name configurations changes successfully completed\n" printINFOLog @@ -287,26 +360,26 @@ fullDeployment(){ LOG_STATEMENT="Creating the gateway worker profile\n" printINFOLog - sh 0_gw/wso2am-4.0.0/bin/profileSetup.sh -Dprofile=gateway-worker + sh 0_gw/$extractedPackDirName/bin/profileSetup.sh -Dprofile=gateway-worker LOG_STATEMENT="Created the gateway worker profile\n" printINFOLog LOG_STATEMENT="Creating the traffic manager profile\n" printINFOLog - sh 1_tm/wso2am-4.0.0/bin/profileSetup.sh -Dprofile=traffic-manager + sh 1_tm/$extractedPackDirName/bin/profileSetup.sh -Dprofile=traffic-manager LOG_STATEMENT="Created the traffic manager profile\n" printINFOLog LOG_STATEMENT="Creating the control plane profile\n" printINFOLog - sh 2_cp/wso2am-4.0.0/bin/profileSetup.sh -Dprofile=control-plane + sh 2_cp/$extractedPackDirName/bin/profileSetup.sh -Dprofile=control-plane LOG_STATEMENT="Created the control plane profile\n" printINFOLog LOG_STATEMENT="Configuring databases by executing scripts\n[APIM_DB] => $APIM_DB_WSO2AM_400\n[SHARED_DB] => $SHARED_DB_WSO2AM_400\nYou need to enter the MySQL root password to continue this step\n" printINFOLog - cd 0_gw/wso2am-4.0.0/dbscripts + cd 0_gw/$extractedPackDirName/dbscripts mysql -u$MYSQL_ROOT_USERNAME -p -e "DROP DATABASE IF EXISTS $APIM_DB_WSO2AM_400; DROP DATABASE IF EXISTS $SHARED_DB_WSO2AM_400; CREATE DATABASE $APIM_DB_WSO2AM_400;CREATE DATABASE $SHARED_DB_WSO2AM_400;USE $APIM_DB_WSO2AM_400;SOURCE apimgt/mysql.sql;USE $SHARED_DB_WSO2AM_400;SOURCE mysql.sql;SHOW TABLES;USE $APIM_DB_WSO2AM_400;SHOW TABLES;" LOG_STATEMENT="Configured databases by executing scripts successfully\n" @@ -314,22 +387,22 @@ fullDeployment(){ cd ../../.. - rm -rf 0_gw/wso2am-4.0.0/repository/conf/deployment.toml - rm -rf 1_tm/wso2am-4.0.0/repository/conf/deployment.toml - rm -rf 2_cp/wso2am-4.0.0/repository/conf/deployment.toml + rm -rf 0_gw/$extractedPackDirName/repository/conf/deployment.toml + rm -rf 1_tm/$extractedPackDirName/repository/conf/deployment.toml + rm -rf 2_cp/$extractedPackDirName/repository/conf/deployment.toml cd ../toml_files - cp gateway-worker.toml ../distributed_deployment/0_gw/wso2am-4.0.0/repository/conf - cp traffic-manager.toml ../distributed_deployment/1_tm/wso2am-4.0.0/repository/conf - cp control-plane.toml ../distributed_deployment/2_cp/wso2am-4.0.0/repository/conf + cp gateway-worker.toml ../distributed_deployment/0_gw/$extractedPackDirName/repository/conf + cp traffic-manager.toml ../distributed_deployment/1_tm/$extractedPackDirName/repository/conf + cp control-plane.toml ../distributed_deployment/2_cp/$extractedPackDirName/repository/conf LOG_STATEMENT="Starting to replacing deployment.toml files in all 3 nodes by taking from the toml_files directory\n" printINFOLog - mv ../distributed_deployment/0_gw/wso2am-4.0.0/repository/conf/gateway-worker.toml ../distributed_deployment/0_gw/wso2am-4.0.0/repository/conf/deployment.toml - mv ../distributed_deployment/1_tm/wso2am-4.0.0/repository/conf/traffic-manager.toml ../distributed_deployment/1_tm/wso2am-4.0.0/repository/conf/deployment.toml - mv ../distributed_deployment/2_cp/wso2am-4.0.0/repository/conf/control-plane.toml ../distributed_deployment/2_cp/wso2am-4.0.0/repository/conf/deployment.toml + mv ../distributed_deployment/0_gw/$extractedPackDirName/repository/conf/gateway-worker.toml ../distributed_deployment/0_gw/$extractedPackDirName/repository/conf/deployment.toml + mv ../distributed_deployment/1_tm/$extractedPackDirName/repository/conf/traffic-manager.toml ../distributed_deployment/1_tm/$extractedPackDirName/repository/conf/deployment.toml + mv ../distributed_deployment/2_cp/$extractedPackDirName/repository/conf/control-plane.toml ../distributed_deployment/2_cp/$extractedPackDirName/repository/conf/deployment.toml LOG_STATEMENT="deployment.toml file replacement is success\n" printINFOLog @@ -340,15 +413,15 @@ fullDeployment(){ printINFOLog # #FOR MAC OS, - # #sed -i '' "s/MYSQL_ROOT_USERNAME/$MYSQL_ROOT_USERNAME/gi" 0_gw/wso2am-4.0.0/repository/conf/deployment.toml + # #sed -i '' "s/MYSQL_ROOT_USERNAME/$MYSQL_ROOT_USERNAME/gi" 0_gw/$extractedPackDirName/repository/conf/deployment.toml - sed -i '' "s/MYSQL_ROOT_USERNAME/$MYSQL_ROOT_USERNAME/gi" 0_gw/wso2am-4.0.0/repository/conf/deployment.toml - sed -i '' "s/MYSQL_ROOT_USERNAME/$MYSQL_ROOT_USERNAME/gi" 1_tm/wso2am-4.0.0/repository/conf/deployment.toml - sed -i '' "s/MYSQL_ROOT_USERNAME/$MYSQL_ROOT_USERNAME/gi" 2_cp/wso2am-4.0.0/repository/conf/deployment.toml + sed -i '' "s/MYSQL_ROOT_USERNAME/$MYSQL_ROOT_USERNAME/gi" 0_gw/$extractedPackDirName/repository/conf/deployment.toml + sed -i '' "s/MYSQL_ROOT_USERNAME/$MYSQL_ROOT_USERNAME/gi" 1_tm/$extractedPackDirName/repository/conf/deployment.toml + sed -i '' "s/MYSQL_ROOT_USERNAME/$MYSQL_ROOT_USERNAME/gi" 2_cp/$extractedPackDirName/repository/conf/deployment.toml - sed -i '' "s/MYSQL_ROOT_PASSWORD/$MYSQL_ROOT_PASSWORD/gi" 0_gw/wso2am-4.0.0/repository/conf/deployment.toml - sed -i '' "s/MYSQL_ROOT_PASSWORD/$MYSQL_ROOT_PASSWORD/gi" 1_tm/wso2am-4.0.0/repository/conf/deployment.toml - sed -i '' "s/MYSQL_ROOT_PASSWORD/$MYSQL_ROOT_PASSWORD/gi" 2_cp/wso2am-4.0.0/repository/conf/deployment.toml + sed -i '' "s/MYSQL_ROOT_PASSWORD/$MYSQL_ROOT_PASSWORD/gi" 0_gw/$extractedPackDirName/repository/conf/deployment.toml + sed -i '' "s/MYSQL_ROOT_PASSWORD/$MYSQL_ROOT_PASSWORD/gi" 1_tm/$extractedPackDirName/repository/conf/deployment.toml + sed -i '' "s/MYSQL_ROOT_PASSWORD/$MYSQL_ROOT_PASSWORD/gi" 2_cp/$extractedPackDirName/repository/conf/deployment.toml LOG_STATEMENT="MySQL root username change is completed successfully files\n" printINFOLog @@ -356,9 +429,9 @@ fullDeployment(){ LOG_STATEMENT="Starting to change [database.shared_db] database name configurations in deployment.toml files\n" printINFOLog - sed -i '' "s/SHARED_DB_WSO2AM_400/$SHARED_DB_WSO2AM_400/gi" 0_gw/wso2am-4.0.0/repository/conf/deployment.toml - sed -i '' "s/SHARED_DB_WSO2AM_400/$SHARED_DB_WSO2AM_400/gi" 1_tm/wso2am-4.0.0/repository/conf/deployment.toml - sed -i '' "s/SHARED_DB_WSO2AM_400/$SHARED_DB_WSO2AM_400/gi" 2_cp/wso2am-4.0.0/repository/conf/deployment.toml + sed -i '' "s/SHARED_DB_WSO2AM_400/$SHARED_DB_WSO2AM_400/gi" 0_gw/$extractedPackDirName/repository/conf/deployment.toml + sed -i '' "s/SHARED_DB_WSO2AM_400/$SHARED_DB_WSO2AM_400/gi" 1_tm/$extractedPackDirName/repository/conf/deployment.toml + sed -i '' "s/SHARED_DB_WSO2AM_400/$SHARED_DB_WSO2AM_400/gi" 2_cp/$extractedPackDirName/repository/conf/deployment.toml LOG_STATEMENT="[database.shared_db] database name configurations changes successfully completed\n" printINFOLog @@ -366,8 +439,8 @@ fullDeployment(){ LOG_STATEMENT="Starting to change [database.apim_db] database name configurations in deployment.toml files\n" printINFOLog - sed -i '' "s/APIM_DB_WSO2AM_400/$APIM_DB_WSO2AM_400/gi" 1_tm/wso2am-4.0.0/repository/conf/deployment.toml - sed -i '' "s/APIM_DB_WSO2AM_400/$APIM_DB_WSO2AM_400/gi" 2_cp/wso2am-4.0.0/repository/conf/deployment.toml + sed -i '' "s/APIM_DB_WSO2AM_400/$APIM_DB_WSO2AM_400/gi" 1_tm/$extractedPackDirName/repository/conf/deployment.toml + sed -i '' "s/APIM_DB_WSO2AM_400/$APIM_DB_WSO2AM_400/gi" 2_cp/$extractedPackDirName/repository/conf/deployment.toml LOG_STATEMENT="[database.apim_db] database name configurations changes successfully completed\n" printINFOLog @@ -392,7 +465,7 @@ extractTheBasePack(){ } init(){ - LOG_STATEMENT="Starting the distributed deployment script of the WSO2 API Manager 4.0.0\n" + LOG_STATEMENT="Starting the distributed deployment script of the WSO2 API Manager $APIM_VERSION\n" printINFOLog LOG_STATEMENT="Created by Sumudu Weerasuriya from the Integration CS Team\n" printINFOLog @@ -432,20 +505,6 @@ init(){ exit 1 fi - if [ -z "$pathToBasePack" ] - then - LOG_STATEMENT="Base pack path is not defined\n" - printERRLog - exit 1 - fi - - if [ -z "$pathToMySQLConnectorFile" ] - then - LOG_STATEMENT="JDBC connector path is not defined\n" - printERRLog - exit 1 - fi - if [ -z "$MYSQL_ROOT_USERNAME" ] then LOG_STATEMENT="MySQL root user name is not defined\n" @@ -477,7 +536,7 @@ init(){ LOG_STATEMENT="\n\nDEPLOYMENT DETAILS \n\n* Deployment Pattern: $deploymentPattern \n* Base Pack Path: $pathToBasePack\n* ZIP Name: $zipFilename\n* Update Level: $UPDATE_LEVEL\n* Directory Name Of The Extracted Content: $extractedPackDirName \n\n" printConfigDetail - LOG_STATEMENT="\n\nDATABASE DETAILS \n\n* JDBC Connector File Path: $pathToMySQLConnectorFile \n* ROOT User Name: $MYSQL_ROOT_USERNAME\n* APIM Database Name: $APIM_DB_WSO2AM_400\n* Shared Database Name: $SHARED_DB_WSO2AM_400\n\n" + LOG_STATEMENT="\n\nDATABASE DETAILS \n\n* ROOT User Name: $MYSQL_ROOT_USERNAME\n* APIM Database Name: $APIM_DB_WSO2AM_400\n* Shared Database Name: $SHARED_DB_WSO2AM_400\n\n" printConfigDetail case "$deploymentPattern" in @@ -508,9 +567,14 @@ printERRLog(){ printf "[${timestamp}] ERROR - $LOG_STATEMENT" } +printWARNLog(){ + getSystemTimestamp + printf "[${timestamp}] WARN - $LOG_STATEMENT" +} + printConfigDetail(){ getSystemTimestamp - printf "[${timestamp}] CONFIG_DETAIL - $LOG_STATEMENT" + printf "[${timestamp}] CONFIG_DETAIL \n$LOG_STATEMENT" } init \ No newline at end of file