Pipelines/Steps/Install/OnPrem/Sitecore/XM/Scaled/9.1/Install-CD.ps1

$ErrorActionPreference = "Stop"

$prefix = $SAFConfiguration.prefix
$license = $SAFConfiguration.license
$sqlServer = $SAFConfiguration.sql.serverName
$sqlSitecorePassword = $SAFConfiguration.sql.sitecorePassword
$package = Get-ChildItem -Path "$SAFInstallPackageDir\*" -Include *cd.scwdp.zip*
$sifConfiguration = GetSIFConfiguration -Name "sitecore-XM1-cd.json" -ContextPath "$PSScriptRoot"
$identityServerUrl = "https://$($SAFConfiguration.identityServer.hostName)"

$serverCert = BuildSitecoreServerCertName -Prefix $prefix
$hostNames = $SAFConfiguration.sitecore.hostNames
$siteName = $hostNames[0]
$installDir = $SAFConfiguration.sitecore.installDir

Write-Output "Install Sitecore CD started..."

$sitecoreParams = @{
    Path                      = $sifConfiguration
    Package                   = $package.FullName
    LicenseFile               = $license
    SqlDbPrefix               = $prefix
    SolrCorePrefix            = $prefix
    Sitename                  = $siteName
    SqlSecurityUser           = "$($prefix)_securityuser"
    SqlSecurityPassword       = $sqlSitecorePassword
    SqlWebUser                = "$($prefix)_webuser"
    SqlWebPassword            = $sqlSitecorePassword
    SqlFormsUser              = "$($prefix)_formsuser"
    SqlFormsPassword          = $sqlSitecorePassword
    SqlServer                 = $sqlServer
    SolrUrl                   = $SAFSolrServiceURL
    SitecoreIdentityAuthority = $identityServerUrl
    InstallDirectory          = $installDir
}
Install-SitecoreConfiguration @sitecoreParams
AddWebBindings -SiteName $siteName -HostNames $hostNames
AddWebBindings -SiteName $siteName -HostNames $hostNames -SSLCert $serverCert
Write-Output "Install Sitecore CD done."