Last active
September 7, 2017 01:22
-
-
Save grant-killian/328f5377e24d8220110269a3d79f2f37 to your computer and use it in GitHub Desktop.
This shows a general approach to easing the human-error potential in step 3 and 4 covered at http://commercesdn.sitecore.net/SitecoreCommerce/DeploymentGuide/en-us/index.html#Concepts/c_M_ChangesToDefaultSettings.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
Author: Grant Killian | |
Created Date: Sept 1, 2017 | |
Ease the human-error potential in step 3 and 4 covered at http://commercesdn.sitecore.net/SitecoreCommerce/DeploymentGuide/en-us/index.html#Concepts/c_M_ChangesToDefaultSettings.html | |
For repetitive installs, it's a pattern that can be used to update a site name etc, too. Here I focus on the SQL Server and Sitecore credentials but other settings could be updated too (just be certain you have the right pattern to match/replace). | |
#> | |
$dbServer ="your db server" #for Azure SQL, something like "qa2-proj-sql.database.windows.net,1433" is what you'd use | |
$dbuser ="SQLuser" | |
$dbpwd = "secret" | |
$CFSolutionStorefrontSite_profilesName = "CFSolutionStorefrontSite_profilesRenamed" | |
$CFSolutionStorefrontSite_productcatalogName = "CFSolutionStorefrontSite_productcatalogRenamed" | |
$SitecoreCommerce_SharedEnvironmentsName = "SitecoreCommerce_SharedEnvironmentsRenamed" | |
$SitecoreCommerce_GlobalName = "SitecoreCommerce_GlobalRenamed" | |
$scuser = "admin" | |
$scpwd = "secret" | |
$theRoot = "S:\Sitecore" | |
########################### shouldn't have to touch anything below here ########################### | |
function updateEnvJSONFile($theFile) | |
{ | |
#in all of these, the white space is critical and note there are 2 spaces between the ":" and the value, typically | |
$original="`"UserName`": `"`"," # $key here that it's a "blank" pwd as there is a sitecore username here too that is not the same value | |
$updated="`"UserName`": `"$dbuser`"," | |
(Get-Content "$theFile").Replace($original, $updated) | Set-Content "$theFile.new" | |
$original="`"Password`": `"`"," | |
$updated="`"Password`": `"$dbpwd`"," | |
(Get-Content "$theFile.new").Replace($original, $updated) | Set-Content "$theFile.new" | |
$original="`"Server`": `".`"," | |
$updated="`"Server`": `"$dbServer`"," | |
(Get-Content "$theFile.new").Replace($original, $updated) | Set-Content "$theFile.new" | |
$original="`"TrustedConnection`": true," | |
$updated="`"TrustedConnection`": false," | |
(Get-Content "$theFile.new").Replace($original, $updated) | Set-Content "$theFile.new" | |
$original="`"UserName`": `"admin`"," | |
$updated="`"UserName`": `"$scuser`"," | |
(Get-Content "$theFile.new").Replace($original, $updated) | Set-Content "$theFile.new" | |
$original="`"Password`": `"b`"" | |
$updated="`"Password`": `"$scpwd`"" | |
(Get-Content "$theFile.new").Replace($original, $updated) | Set-Content "$theFile.new" | |
<# every json file references these three databases by name only: | |
"Database": "CFSolutionStorefrontSite_profiles", | |
"Database": "SitecoreCommerce_SharedEnvironments", | |
"Database": "CFSolutionStorefrontSite_productcatalog", | |
#> | |
$original="`"Database`": `"CFSolutionStorefrontSite_profiles`"," | |
$updated ="`"Database`": `"$CFSolutionStorefrontSite_profilesName`"," | |
(Get-Content "$theFile.new").Replace($original, $updated) | Set-Content "$theFile.new" | |
$original="`"Database`": `"SitecoreCommerce_SharedEnvironments`"," | |
$updated ="`"Database`": `"$SitecoreCommerce_SharedEnvironmentsName`"," | |
(Get-Content "$theFile.new").Replace($original, $updated) | Set-Content "$theFile.new" | |
$original="`"Database`": `"CFSolutionStorefrontSite_productcatalog`"," | |
$updated ="`"Database`": `"$CFSolutionStorefrontSite_productcatalogName`"," | |
(Get-Content "$theFile.new").Replace($original, $updated) | Set-Content "$theFile.new" | |
} | |
function updateGlobalFile() | |
{ | |
$jsonGlobal = "$theRoot\CommerceAuthoring\wwwroot\bootstrap\Global.json" | |
$original="`"Database`": `"SitecoreCommerce_Global`"," | |
$updated="`"Database`": `"$SitecoreCommerce_GlobalName`"," | |
(Get-Content $jsonGlobal).Replace($original, $updated) | Set-Content "$jsonGlobal.new" | |
$original="`"Password`": `"`"," | |
$updated="`"Password`": `"$dbpwd`"," | |
(Get-Content "$jsonGlobal.new").Replace($original, $updated) | Set-Content "$jsonGlobal.new" | |
$original="`"Server`": `"`.`"," | |
$updated="`"Server`": `"$dbServer`"," | |
(Get-Content "$jsonGlobal.new").Replace($original, $updated) | Set-Content "$jsonGlobal.new" | |
$original="`"UserName`": `"`"," | |
$updated="`"UserName`": `"$dbuser`"," | |
(Get-Content "$jsonGlobal.new").Replace($original, $updated) | Set-Content "$jsonGlobal.new" | |
$original="`"TrustedConnection`": true," | |
$updated="`"TrustedConnection`": false," | |
(Get-Content "$jsonGlobal.new").Replace($original, $updated) | Set-Content "$jsonGlobal.new" | |
} | |
$json1 = "$theRoot\CommerceAuthoring\wwwroot\data\Environments\PlugIn.AdventureWorks.CommerceAuthoring-1.0.0.json" | |
$json2 = "$theRoot\CommerceAuthoring\wwwroot\data\Environments\PlugIn.AdventureWorks.CommerceMinions-1.0.0.json" | |
$json3 = "$theRoot\CommerceAuthoring\wwwroot\data\Environments\PlugIn.AdventureWorks.CommerceShops-1.0.0.json" | |
$json4 = "$theRoot\CommerceAuthoring\wwwroot\data\Environments\PlugIn.Habitat.CommerceAuthoring-1.0.0.json" | |
$json5 = "$theRoot\CommerceAuthoring\wwwroot\data\Environments\PlugIn.Habitat.CommerceMinions-1.0.0.json" | |
$json6 = "$theRoot\CommerceAuthoring\wwwroot\data\Environments\PlugIn.Habitat.CommerceShops-1.0.0.json" | |
updateGlobalFile | |
updateEnvJSONFile $json1 | |
updateEnvJSONFile $json2 | |
updateEnvJSONFile $json3 | |
updateEnvJSONFile $json4 | |
updateEnvJSONFile $json5 | |
updateEnvJSONFile $json6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment