Pipelines/Steps/Install/OnPrem/Sitecore/XP/Scaled/9.1/Install-PRC.ps1

$ErrorActionPreference = "Stop"

$prefix = $SAFConfiguration.prefix
$siteName = $SAFConfiguration.processing.hostName
$hostNames = @($siteName)
$license = $SAFConfiguration.license
$sqlServer = $SAFConfiguration.sql.serverName
$sqlUser = $SAFConfiguration.sql.adminUsername
$sqlAdminPassword = $SAFConfiguration.sql.adminPassword
$sqlSitecorePassword = $SAFConfiguration.sql.sitecorePassword
$solrURL = $SAFSolrServiceURL
$collectionService = $SAFConfiguration.xConnect.collectionServiceURL
$installDir = $SAFConfiguration.processing.installDir
$reportingServiceApiKey = $SAFConfiguration.reporting.serviceApiKey
$package = Get-ChildItem -Path "$SAFInstallPackageDir\*" -Include *prc.scwdp.zip*
$sifConfiguration = GetSIFConfiguration -Name "sitecore-XP1-prc.json" -ContextPath "$PSScriptRoot"

$clientCert = BuildSitecoreClientCertName -Prefix $prefix
$serverCert = BuildSitecoreServerCertName -Prefix $prefix

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

$dbs = @("$($prefix)_Processing.Tasks")
DeleteDatabases -SqlServer $sqlServer -Databases $dbs -Username $sqlUser -Password $sqlAdminPassword

$sitecoreParams = @{
    Path = $sifConfiguration
    Package = $package.FullName
    LicenseFile = $license
    XConnectCert = $clientCert
    SSLCert = $serverCert
    SqlDbPrefix = $prefix
    SolrCorePrefix = $prefix
    Sitename = $siteName
    SqlAdminUser = $sqlUser
    SqlAdminPassword = $sqlAdminPassword
    SqlCoreUser = "$($prefix)_coreuser"
    SqlCorePassword = $sqlSitecorePassword
    SqlSecurityUser = "$($prefix)_securityuser"
    SqlSecurityPassword = $sqlSitecorePassword
    SqlMasterUser = "$($prefix)_masteruser"
    SqlMasterPassword = $sqlSitecorePassword
    SqlReportingUser = "$($prefix)_reportinguser"
    SqlReportingPassword = $sqlSitecorePassword
    SqlReferenceDataUser = "$($prefix)_referencedatauser"
    SqlReferenceDataPassword = $sqlSitecorePassword
    SqlProcessingPoolsUser = "$($prefix)_processingpoolsuser"
    SqlProcessingPoolsPassword = $sqlSitecorePassword
    SqlProcessingTasksUser = "$($prefix)_processingtasksuser"
    SqlProcessingTasksPassword = $sqlSitecorePassword
    SqlServer = $sqlServer
    XConnectCollectionService = $collectionService
    ReportingServiceApiKey = $reportingServiceApiKey
    InstallDirectory = $installDir
}

Install-SitecoreConfiguration @sitecoreParams
AddWebBindings -SiteName $siteName -HostNames $hostNames
AddWebBindings -SiteName $siteName -HostNames $hostNames -SSLCert $serverCert

Write-Output "Install Sitecore Processing done."