Commit c190ade3 authored by Viet Hoang's avatar Viet Hoang
Browse files

add Scripts for Sitecore Commerce 9

parent 982b1bad
......@@ -15,7 +15,7 @@
<!-- SCHEDULING -->
<scheduling>
<frequency>10:00:05</frequency>
<frequency>00:00:00</frequency>
</scheduling>
</sitecore>
</configuration>
\ No newline at end of file
......@@ -17,7 +17,7 @@ Function Invoke-InstallModuleTask {
Write-Host "Installing module: " $moduleToInstall -ForegroundColor Green ;
$urlInstallModules = $BaseUrl + "/InstallModules.aspx?modules=" + $moduleToInstall
Write-Host $urlInstallModules
Invoke-RestMethod $urlInstallModules -TimeoutSec 720
Invoke-RestMethod $urlInstallModules -TimeoutSec 7200
}
Function Invoke-InstallPackageTask {
......@@ -38,7 +38,7 @@ Function Invoke-InstallPackageTask {
Write-Host "Installing package: " $packageToInstall -ForegroundColor Green ;
$urlInstallPackages = $BaseUrl + "/InstallPackages.aspx?package=" + $packageToInstall
Write-Host $urlInstallPackages
Invoke-RestMethod $urlInstallPackages -TimeoutSec 720
Invoke-RestMethod $urlInstallPackages -TimeoutSec 7200
}
Function Invoke-PublishToWebTask {
......@@ -50,7 +50,7 @@ Function Invoke-PublishToWebTask {
Write-Host "Publishing to web..." -ForegroundColor Green ;
$urlPublish = $BaseUrl + "/Publish.aspx"
Invoke-RestMethod $urlPublish -TimeoutSec 720
Invoke-RestMethod $urlPublish -TimeoutSec 7200
Write-Host "Publishing to web complete..." -ForegroundColor Green ;
}
......@@ -92,7 +92,7 @@ Function Invoke-CreateDefaultStorefrontTask {
Try
{
$urlPowerShellScript = $BaseUrl + "/-/script/v2/master/$($scriptName)?user=$($sitecoreUsername)&password=$($sitecoreUserPassword)"
Invoke-RestMethod $urlPowerShellScript -TimeoutSec 1200
Invoke-RestMethod $urlPowerShellScript -TimeoutSec 12000
}
Catch
{
......@@ -112,17 +112,17 @@ Function Invoke-RebuildIndexesTask {
Write-Host "Rebuilding index 'sitecore_core_index' ..." -ForegroundColor Green ;
$urlRebuildIndex = $BaseUrl + "/RebuildIndex.aspx?index=sitecore_core_index"
Invoke-RestMethod $urlRebuildIndex -TimeoutSec 300
Invoke-RestMethod $urlRebuildIndex -TimeoutSec 3000
Write-Host "Rebuilding index 'sitecore_core_index' completed." -ForegroundColor Green ;
Write-Host "Rebuilding index 'sitecore_master_index' ..." -ForegroundColor Green ;
$urlRebuildIndex = $BaseUrl + "/RebuildIndex.aspx?index=sitecore_master_index"
Invoke-RestMethod $urlRebuildIndex -TimeoutSec 600
Invoke-RestMethod $urlRebuildIndex -TimeoutSec 6000
Write-Host "Rebuilding index 'sitecore_master_index' completed." -ForegroundColor Green ;
Write-Host "Rebuilding index 'sitecore_web_index' ..." -ForegroundColor Green ;
$urlRebuildIndex = $BaseUrl + "/RebuildIndex.aspx?index=sitecore_web_index"
Invoke-RestMethod $urlRebuildIndex -TimeoutSec 600
Invoke-RestMethod $urlRebuildIndex -TimeoutSec 6000
Write-Host "Rebuilding index 'sitecore_web_index' completed." -ForegroundColor Green ;
}
......@@ -135,7 +135,7 @@ Function Invoke-GenerateCatalogTemplatesTask {
Write-Host "Generating Catalog Templates ..." -ForegroundColor Green ;
$urlGenerate = $BaseUrl + "/GenerateCatalogTemplates.aspx"
Invoke-RestMethod $urlGenerate -TimeoutSec 180
Invoke-RestMethod $urlGenerate -TimeoutSec 1800
Write-Host "Generating Catalog Templates completed." -ForegroundColor Green ;
}
......
#Requires -Version 3
param(
[string]$SiteName = "sc901three.local",
[string]$SiteHostHeaderName = "storefont.local",
[string]$SqlDbPrefix = "sc901three",
[string]$CommerceSearchProvider = "SOLR"
[string]$SiteName = "sc901com.local",
[string]$ScInstallDirectory = "F:\Sitecore Training",
[string]$SiteHostHeaderName = "storefont.local",
[string]$SqlServer = "DESKTOP-XXXXXX\MSSQLSERVER2017",
[string]$SqlDbPrefix = "sc901com",
[string]$CommerceEngineCertificatePath = "..\storefont.local.cer",
[string]$CommerceSearchProvider = "SOLR",
[string]$SolrUrl = "https://localhost:8983/solr",
[string]$SolrRoot = "e:\sc9_install\solr-6.6.2",
[string]$SolrService = "Solr_6.6.2"
)
$global:DEPLOYMENT_DIRECTORY=Split-Path $MyInvocation.MyCommand.Path
......@@ -20,24 +26,24 @@ $params = @{
Path = Resolve-Path '.\Configuration\Commerce\Master_SingleServer.json'
SiteName = $SiteName
SiteHostHeaderName = $SiteHostHeaderName
InstallDir = "F:\Sitecore Training\$($SiteName)"
XConnectInstallDir = "F:\Sitecore Training\$($SiteName)_xconnect"
InstallDir = "$($ScInstallDirectory)\$($SiteName)"
XConnectInstallDir = "$($ScInstallDirectory)\$($SiteName)_xconnect"
CertificateName = $SiteName
CommerceServicesDbServer = "DESKTOP-3VJQ1BB\MSSQLSERVER2017"
CommerceServicesDbName = "SitecoreCommerce9_SharedEnvironments"
CommerceServicesGlobalDbName = "SitecoreCommerce9_Global"
SitecoreDbServer = "DESKTOP-3VJQ1BB\MSSQLSERVER2017"
SitecoreDbServer = "$($SqlServer)"
SitecoreCoreDbName = "$($SqlDbPrefix)_Core"
CommerceSearchProvider = $CommerceSearchProvider
SolrUrl = "https://localhost:8983/solr"
SolrRoot = "e:\sc9_install\solr-6.6.2"
SolrService = "Solr_6.6.2"
SolrUrl = "$($SolrUrl)"
SolrRoot = "$($SolrRoot)"
SolrService = "$($SolrService)"
SolrSchemas = ( Join-Path -Path $DEPLOYMENT_DIRECTORY -ChildPath "SolrSchemas" )
SearchIndexPrefix = ""
AzureSearchServiceName = ""
AzureSearchAdminKey = ""
AzureSearchQueryKey = ""
CommerceEngineDacPac = Resolve-Path -Path "..\Sitecore.Commerce.Engine.SDK.*\Sitecore.Commerce.Engine.DB.dacpac"
CommerceEngineDacPac = Resolve-Path -Path "..\Sitecore.Commerce.Engine.DB.dacpac"
CommerceOpsServicesPort = "5015"
CommerceShopsServicesPort = "5005"
CommerceAuthoringServicesPort = "5000"
......@@ -45,7 +51,7 @@ $params = @{
SitecoreCommerceEngineZipPath = Resolve-Path -Path "..\Sitecore.Commerce.Engine.2.*.zip"
SitecoreBizFxServicesContentPath = Resolve-Path -Path "..\Sitecore.BizFX.1.0.572"
SitecoreIdentityServerZipPath = Resolve-Path -Path "..\Sitecore.IdentityServer.1.*.zip"
CommerceEngineCertificatePath = Resolve-Path -Path "..\sc9com.cer"
CommerceEngineCertificatePath = Resolve-Path -Path "$($CommerceEngineCertificatePath)"
SiteUtilitiesSrc = ( Join-Path -Path $DEPLOYMENT_DIRECTORY -ChildPath "SiteUtilityPages" )
HabitatImagesModuleFullPath = Resolve-Path -Path "..\Sitecore.Commerce.Habitat.Images-*.zip"
AdvImagesModuleFullPath = Resolve-Path -Path "..\Adventure Works Images.zip"
......@@ -57,11 +63,11 @@ $params = @{
SXAStorefrontModuleFullPath = Resolve-Path -Path "..\Sitecore Commerce Experience Accelerator Storefront 1.*.zip"
SXAStorefrontThemeModuleFullPath = Resolve-Path -Path "..\Sitecore Commerce Experience Accelerator Storefront Themes*.zip"
SXAStorefrontCatalogModuleFullPath = Resolve-Path -Path "..\Sitecore Commerce Experience Accelerator Habitat Catalog*.zip"
MergeToolFullPath = Resolve-Path -Path "..\MSBuild.Microsoft.VisualStudio.Web.targets.14.0.0.3\tools\VSToolsPath\Web\Microsoft.Web.XmlTransform.dll"
MergeToolFullPath = Resolve-Path -Path "..\Microsoft.Web.XmlTransform.dll"
UserAccount = @{
Domain = $Env:COMPUTERNAME
UserName = 'Viet Hoang'
Password = 'Zen732010'
UserName = 'WindowUserName'
Password = 'WindowUserPassword'
}
BraintreeAccount = @{
MerchantId = ''
......
#define parameters
Param(
[string]$Prefix = 'sc901com',
[string]$CommerceOpsSiteName = 'CommerceOps_Sc9',
[string]$CommerceShopsSiteName = 'CommerceShops_Sc9',
[string]$CommerceAuthoringSiteName = 'CommerceAuthoring_Sc9',
[string]$CommerceMinionsSiteName = 'CommerceMinions_Sc9',
[string]$SitecoreBizFxSiteName = 'SitecoreBizFx',
[string]$SitecoreIdentityServerSiteName = 'SitecoreIdentityServer',
[string]$SolrService = 'Solr_6.6.2',
[string]$PathToSolr = 'E:\sc9_install\solr-6.6.2\',
[string]$SqlServer = 'DESKTOP-XXXXXX\MSSQLSERVER2017',
[string]$SqlAccount = 'sa',
[string]$SqlPassword = 'password'
)
#Write-TaskHeader function modified from SIF
Function Write-TaskHeader {
param(
[Parameter(Mandatory=$true)]
[string]$TaskName,
[Parameter(Mandatory=$true)]
[string]$TaskType
)
function StringFormat {
param(
[int]$length,
[string]$value,
[string]$prefix = '',
[string]$postfix = '',
[switch]$padright
)
# wraps string in spaces so we reduce length by two
$length = $length - 2 #- $postfix.Length - $prefix.Length
if($value.Length -gt $length){
# Reduce to length - 4 for elipsis
$value = $value.Substring(0, $length - 4) + '...'
}
$value = " $value "
if($padright){
$value = $value.PadRight($length, '*')
} else {
$value = $value.PadLeft($length, '*')
}
return $prefix + $value + $postfix
}
$actualWidth = (Get-Host).UI.RawUI.BufferSize.Width
$width = $actualWidth - ($actualWidth % 2)
$half = $width / 2
$leftString = StringFormat -length $half -value $TaskName -prefix '[' -postfix ':'
$rightString = StringFormat -length $half -value $TaskType -postfix ']' -padright
$message = ($leftString + $rightString)
Write-Host ''
Write-Host $message -ForegroundColor 'Red'
}
Function Remove-Service{
[CmdletBinding()]
param(
[string]$serviceName
)
if(Get-Service "My Service" -ErrorAction SilentlyContinue){
sc.exe delete $serviceName
}
}
Function Remove-Website{
[CmdletBinding()]
param(
[string]$siteName
)
$appCmd = "C:\windows\system32\inetsrv\appcmd.exe"
& $appCmd delete site $siteName
}
Function Remove-AppPool{
[CmdletBinding()]
param(
[string]$appPoolName
)
$appCmd = "C:\windows\system32\inetsrv\appcmd.exe"
& $appCmd delete apppool $appPoolName
}
#Stop Solr Service
Write-TaskHeader -TaskName "Solr Services" -TaskType "Stop"
Write-Host "Stopping solr service"
Stop-Service $SolrService -Force -ErrorAction stop
Write-Host "Solr service stopped successfully"
#Delete solr cores
Write-TaskHeader -TaskName "Solr Services" -TaskType "Delete Cores"
Write-Host "Deleting Solr Cores"
$pathToCores = "$pathToSolr\server\solr\$Prefix*"
Remove-Item $pathToCores -recurse -force -ErrorAction stop
Write-Host "Solr Cores deleted successfully"
#Remove Sites and App Pools from IIS
Write-TaskHeader -TaskName "Internet Information Services" -TaskType "Remove Websites"
Write-Host "Deleting Website $CommerceOpsSiteName"
Remove-Website -siteName $CommerceOpsSiteName -ErrorAction stop
Write-Host "Websites deleted"
Write-Host "Deleting Website $CommerceShopsSiteName"
Remove-Website -siteName $CommerceShopsSiteName -ErrorAction stop
Write-Host "Websites deleted"
Write-Host "Deleting Website $CommerceAuthoringSiteName"
Remove-Website -siteName $CommerceAuthoringSiteName -ErrorAction stop
Write-Host "Websites deleted"
Write-Host "Deleting Website $CommerceMinionsSiteName "
Remove-Website -siteName $CommerceMinionsSiteName -ErrorAction stop
Write-Host "Websites deleted"
Write-Host "Deleting Website $SitecoreBizFxSiteName"
Remove-Website -siteName $SitecoreBizFxSiteName -ErrorAction stop
Write-Host "Websites deleted"
Write-Host "Deleting Website $SitecoreIdentityServerSiteName"
Remove-Website -siteName $SitecoreIdentityServerSiteName -ErrorAction stop
Write-Host "Websites deleted"
Remove-AppPool -appPoolName $CommerceOpsSiteName -ErrorAction stop
Write-Host "Application pools deleted"
Remove-AppPool -appPoolName $CommerceShopsSiteName -ErrorAction stop
Write-Host "Application pools deleted"
Remove-AppPool -appPoolName $CommerceAuthoringSiteName -ErrorAction stop
Write-Host "Application pools deleted"
Remove-AppPool -appPoolName $CommerceMinionsSiteName -ErrorAction stop
Write-Host "Application pools deleted"
Remove-AppPool -appPoolName $SitecoreBizFxSiteName -ErrorAction stop
Write-Host "Application pools deleted"
Remove-AppPool -appPoolName $SitecoreIdentityServerSiteName -ErrorAction stop
Remove-Item C:\inetpub\wwwroot\$CommerceOpsSiteName -recurse -force -ErrorAction stop
Write-Host "Websites removed from wwwroot"
Remove-Item C:\inetpub\wwwroot\$CommerceShopsSiteName -recurse -force -ErrorAction stop
Write-Host "Websites removed from wwwroot"
Remove-Item C:\inetpub\wwwroot\$CommerceAuthoringSiteName -recurse -force -ErrorAction stop
Write-Host "Websites removed from wwwroot"
Remove-Item C:\inetpub\wwwroot\$CommerceMinionsSiteName -recurse -force -ErrorAction stop
Write-Host "Websites removed from wwwroot"
Remove-Item C:\inetpub\wwwroot\$SitecoreBizFxSiteName -recurse -force -ErrorAction stop
Write-Host "Websites removed from wwwroot"
Remove-Item C:\inetpub\wwwroot\$SitecoreIdentityServerSiteName -recurse -force -ErrorAction stop
Write-Host "Websites removed from wwwroot"
Write-TaskHeader -TaskName "SQL Server" -TaskType "Drop Databases"
#Drop databases from SQL
Write-Host "Dropping databases from SQL server"
push-location
import-module sqlps
Write-Host $("Dropping database SitecoreCommerce9_Global")
$commerceDbPrefix = $("DROP DATABASE IF EXISTS [SitecoreCommerce9_Global]")
Write-Host $("Query: $($commerceDbPrefix)")
invoke-sqlcmd -ServerInstance $SqlServer -U $SqlAccount -P $SqlPassword -Query $commerceDbPrefix -ErrorAction stop
Write-Host $("Dropping database [SitecoreCommerce9_SharedEnvironments]")
$sharedDbPrefix = $("DROP DATABASE IF EXISTS [SitecoreCommerce9_SharedEnvironments]")
Write-Host $("Query: $($sharedDbPrefix)")
invoke-sqlcmd -ServerInstance $SqlServer -U $SqlAccount -P $SqlPassword -Query $sharedDbPrefix -ErrorAction stop
Write-Host "Databases dropped successfully"
pop-location
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment