Skip to content

Commit 52288bc

Browse files
authored
Merge pull request #908 from rashmithachamikara/rashmitha/fix/fs-is-merge.ps1-updates
Update power-shell scripts to the bash counterparts
2 parents 8ab765f + f8df682 commit 52288bc

File tree

2 files changed

+46
-23
lines changed

2 files changed

+46
-23
lines changed

financial-services-accelerator/accelerators/fs-apim/bin/configure.ps1

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,15 @@ Function Set-Hostnames {
139139
Find-Replace $DEPLOYMENT_TOML_FILE "IS_HOSTNAME" "$( $PROPERTIES.'IS_HOSTNAME' )"
140140
}
141141

142+
# A function to replace the admin credential variables in the temp deployment.toml with their actual values from configure.properties
143+
Function Set-AdminCredentials {
144+
Find-Replace $DEPLOYMENT_TOML_FILE "IS_ADMIN_USERNAME" "$( $PROPERTIES.'IS_ADMIN_USERNAME' )"
145+
Find-Replace $DEPLOYMENT_TOML_FILE "IS_ADMIN_PASSWORD" "$( $PROPERTIES.'IS_ADMIN_PASSWORD' )"
146+
Find-Replace $DEPLOYMENT_TOML_FILE "AM_ADMIN_USERNAME" "$( $PROPERTIES.'AM_ADMIN_USERNAME' )"
147+
Find-Replace $DEPLOYMENT_TOML_FILE "AM_ADMIN_PASSWORD" "$( $PROPERTIES.'AM_ADMIN_PASSWORD' )"
148+
Find-Replace $DEPLOYMENT_TOML_FILE "AM_ADMIN_NAME" "$( $PROPERTIES.'AM_ADMIN_NAME' )"
149+
}
150+
142151
# A utility function to create a database.
143152
Function Add-Database {
144153
param ([string]$DB_USER, [string]$DB_PASS, [string]$DB_HOST, [string]$DB_NAME)
@@ -208,6 +217,11 @@ Write-Output "[INFO] Configuring the hostnames..."
208217
Set-Hostnames
209218
Write-Output "[INFO] Hostnames configurations completed!"
210219

220+
Write-Output "============================================"
221+
Write-Output "[INFO] Configuring the admin credentials..."
222+
Set-AdminCredentials
223+
Write-Output "[INFO] Admin credentials configurations completed!"
224+
211225
Write-Output "============================================"
212226
Write-Output "[INFO] Configuring the datasources..."
213227
Set-Datasources

financial-services-accelerator/accelerators/fs-is/bin/merge.ps1

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -70,53 +70,62 @@ Get-ChildItem (Join-Path $WSO2_BASE_PRODUCT_HOME "repository\components\dropins"
7070
Get-ChildItem (Join-Path $WSO2_BASE_PRODUCT_HOME "repository\components\lib") | Where-Object{$_.Name -Match "org.wso2.financial.services.accelerator.*"} | Remove-Item
7171
Write-Output "[INFO] All previous FS artifacts have been deleted!"
7272

73-
# Copying all the new FS artifacts to the base product
74-
# Copy-Item -Force -Recurse -Verbose (Join-Path $WSO2_ACCELERATOR_HOME "carbon-home\*") -Destination $WSO2_BASE_PRODUCT_HOME
75-
# Using Robocopy.exe becuase powershell Copy-Item cmdlet doesn't do recursive copying after a certain number of subdirectories.
76-
Write-Output "[INFO] Copying new financial services artifacts..."
77-
Robocopy.exe (Join-Path $WSO2_ACCELERATOR_HOME "carbon-home") $WSO2_BASE_PRODUCT_HOME * /E /NFL /NDL /NJH /NJS /nc /ns /np
78-
Write-Output "[INFO] All the new FS artifacts has been copied!"
79-
8073
$WEB_APPS_PATH = (Join-Path $WSO2_BASE_PRODUCT_HOME "repository\deployment\server\webapps")
8174

82-
# Delete the consentmgr web app if it exists.
75+
# Backup and delete the existing consentmgr web app BEFORE copying new artifacts.
8376
$CONSENTMGR_PATH = (Join-Path $WEB_APPS_PATH "consentmgr")
8477
$CONSENTMGR_RUNTIME_JS_PATH = (Join-Path $CONSENTMGR_PATH "runtime-config.js")
8578
$CONSENTMGR_RUNTIME_JS_BACKUP_PATH = (Join-Path $WEB_APPS_PATH "runtime-config.js")
79+
$CONSENTMGR_CONFIG_DIR_PATH = (Join-Path $CONSENTMGR_PATH "WEB-INF\classes")
80+
$CONSENTMGR_CONFIG_FILE_PATH = (Join-Path $CONSENTMGR_CONFIG_DIR_PATH "configurations.properties")
81+
$CONSENTMGR_CONFIG_BACKUP_PATH = (Join-Path $WEB_APPS_PATH "configurations.properties")
8682
if (Test-Path $CONSENTMGR_PATH) {
8783
Write-Output "[INFO] consentmgr web app detected at `"$CONSENTMGR_PATH`""
88-
84+
8985
if (Test-Path $CONSENTMGR_RUNTIME_JS_PATH -PathType Leaf) {
90-
# If the consentmgr/runtime-config,js file exists, backup it to the webapps directory before deleting the directory
86+
# Backup runtime-config.js to webapps directory before deleting the consentmgr directory
9187
Write-Output "[INFO] Copying $CONSENTMGR_RUNTIME_JS_PATH to $CONSENTMGR_RUNTIME_JS_BACKUP_PATH..."
9288
Copy-Item $CONSENTMGR_RUNTIME_JS_PATH -Destination $CONSENTMGR_RUNTIME_JS_BACKUP_PATH -Force
89+
Write-Output "[INFO] Backup of runtime-config.js complete!"
90+
}
91+
92+
if (Test-Path $CONSENTMGR_CONFIG_FILE_PATH -PathType Leaf) {
93+
# Backup configurations.properties to webapps directory before deleting the consentmgr directory
94+
Write-Output "[INFO] Copying $CONSENTMGR_CONFIG_FILE_PATH to $CONSENTMGR_CONFIG_BACKUP_PATH..."
95+
Copy-Item $CONSENTMGR_CONFIG_FILE_PATH -Destination $CONSENTMGR_CONFIG_BACKUP_PATH -Force
96+
Write-Output "[INFO] Backup of configurations.properties complete!"
9397
}
9498

9599
Write-Output "[INFO] Deleting the current consentmgr web app..."
96100
Remove-Item -LiteralPath $CONSENTMGR_PATH -Force -Recurse
97101
Write-Output "[INFO] Deleted the current consentmgr web app!"
98102
}
99103

100-
$CONSENTMGR_PATH_WAR = (Join-Path $WEB_APPS_PATH "consentmgr.war")
101-
$CONSENTMGR_PATH_ZIP = (Join-Path $WEB_APPS_PATH "consentmgr.zip")
102-
103-
# Expand-Archive cmdlet cannot directly extract the .war files. Since .war files are just zip files with some custom file headers and a fancy extension
104-
# we can just rename the war file and extract it.
105-
Move-Item -Path $CONSENTMGR_PATH_WAR -Destination $CONSENTMGR_PATH_ZIP -Force
106-
107-
# Extract the consentmgr.zip
108-
Write-Output "[INFO] Extracting the new consentmgr..."
109-
Expand-Archive -LiteralPath $CONSENTMGR_PATH_ZIP -DestinationPath $CONSENTMGR_PATH -Force
110-
Write-Output "[INFO] New consentmgr extracted!"
104+
# Copying all the new FS artifacts to the base product (includes fresh consentmgr directory from carbon-home)
105+
# Copy-Item -Force -Recurse -Verbose (Join-Path $WSO2_ACCELERATOR_HOME "carbon-home\*") -Destination $WSO2_BASE_PRODUCT_HOME
106+
# Using Robocopy.exe becuase powershell Copy-Item cmdlet doesn't do recursive copying after a certain number of subdirectories.
107+
Write-Output "[INFO] Copying new financial services artifacts..."
108+
Robocopy.exe (Join-Path $WSO2_ACCELERATOR_HOME "carbon-home") $WSO2_BASE_PRODUCT_HOME * /E /NFL /NDL /NJH /NJS /nc /ns /np
109+
Write-Output "[INFO] All the new FS artifacts has been copied!"
111110

111+
# Restore backed up runtime-config.js into the newly copied consentmgr directory
112112
if (Test-Path $CONSENTMGR_RUNTIME_JS_BACKUP_PATH -PathType Leaf) {
113-
# Copy back the backed up runtime-config.js
114113
Write-Output "[INFO] Copying $CONSENTMGR_RUNTIME_JS_BACKUP_PATH to $CONSENTMGR_RUNTIME_JS_PATH..."
115114
Copy-Item $CONSENTMGR_RUNTIME_JS_BACKUP_PATH -Destination $CONSENTMGR_RUNTIME_JS_PATH -Force
116115
Remove-Item -LiteralPath $CONSENTMGR_RUNTIME_JS_BACKUP_PATH -Force
116+
Write-Output "[INFO] Restoring backup runtime-config.js file complete!"
117117
}
118118

119-
Remove-Item -LiteralPath $CONSENTMGR_PATH_ZIP -Force
119+
# Restore backed up configurations.properties into the newly copied consentmgr directory
120+
if (Test-Path $CONSENTMGR_CONFIG_BACKUP_PATH -PathType Leaf) {
121+
Write-Output "[INFO] Copying $CONSENTMGR_CONFIG_BACKUP_PATH to $CONSENTMGR_CONFIG_FILE_PATH..."
122+
if (-NOT(Test-Path $CONSENTMGR_CONFIG_DIR_PATH)) {
123+
New-Item -ItemType Directory -Path $CONSENTMGR_CONFIG_DIR_PATH -Force | Out-Null
124+
}
125+
Copy-Item $CONSENTMGR_CONFIG_BACKUP_PATH -Destination $CONSENTMGR_CONFIG_FILE_PATH -Force
126+
Remove-Item -LiteralPath $CONSENTMGR_CONFIG_BACKUP_PATH -Force
127+
Write-Output "[INFO] Restoring backup configurations.properties file complete!"
128+
}
120129

121130
Write-Output "[INFO] Completed!"
122131

0 commit comments

Comments
 (0)