forked from jraps20/Solr-AzureAppService
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeploy-SolrAzureAppService.ps1
More file actions
109 lines (86 loc) · 3.8 KB
/
Deploy-SolrAzureAppService.ps1
File metadata and controls
109 lines (86 loc) · 3.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
Param(
$solrVersion
)
$solrName = "solr-$solrVersion"
Write-Output 'Setting Security to TLS 1.2'
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Write-Output 'Prevent the progress meter from trying to access the console'
$global:progressPreference = 'SilentlyContinue'
$siteRoot = "D:\home\site\wwwroot"
Write-Output "Downloading Solr $solrVersion tar to D:\home\site"
# $downloadSource = "https://archive.apache.org/dist/lucene/solr/$solrVersion/$solrName.zip"
# utilize new url https://www.apache.org/dyn/closer.lua/solr/solr/9.8.1/solr-9.8.1.tgz?action=download
$downloadSource = "https://www.apache.org/dyn/closer.lua/solr/solr/$solrVersion/$solrName.tgz?action=download"
Invoke-WebRequest -Uri $downloadSource -UseBasicParsing -OutFile "..\solr.tgz"
Write-Output "Expanding Solr zip at D:\home\site directory as D:\home\site\$solrName"
# Expand-Archive "..\solr.zip" -DestinationPath "..\"
tar -xzf "..\solr.tgz" -C "..\"
Write-Output "Copying contents of D:\home\site\$solrName to D:\home\site\wwwroot"
xcopy "..\$solrName\*" "..\wwwroot" /S /Y
Write-Output 'Copy web.config from repository to D:\home\site\wwwroot'
xcopy web.config ..\wwwroot /Y
Write-Output 'Copy default configset as sitecore'
$usingDefault = $false
if (Test-Path "..\wwwroot\server\solr\configsets\_default" -PathType Any) {
$usingDefault = $true
xcopy "..\wwwroot\server\solr\configsets\_default\*.*" "..\wwwroot\server\solr\configsets\sitecore\*" /s/h/e/k/f/c/Y
}
else {
xcopy "..\wwwroot\server\solr\configsets\basic_configs\*.*" "..\wwwroot\server\solr\configsets\sitecore\*" /s/h/e/k/f/c/Y
}
Write-Output 'Modifying uniqueKey of sitecore configset'
$xml = New-Object XML
$path = "..\wwwroot\server\solr\configsets\sitecore\conf\managed-schema"
$xml.Load($path)
$uniqueKey = $xml.SelectSingleNode("//uniqueKey")
$uniqueKey.InnerText = "_uniqueid"
$field = $xml.CreateElement("field")
$field.SetAttribute("name", "_uniqueid")
$field.SetAttribute("type", "string")
$field.SetAttribute("indexed", "true")
$field.SetAttribute("required", "true")
$field.SetAttribute("stored", "true")
$xml.DocumentElement.AppendChild($field)
$xml.Save($path)
$sitecoreCores = @(
"sitecore_analytics_index",
"sitecore_core_index",
"sitecore_fxm_master_index",
"sitecore_fxm_web_index",
"sitecore_list_index",
"sitecore_marketing_asset_index_master",
"sitecore_marketing_asset_index_web",
"sitecore_marketingdefinitions_master",
"sitecore_marketingdefinitions_web",
"sitecore_master_index",
"sitecore_suggested_test_index",
"sitecore_testing_index",
"sitecore_web_index",
"social_messages_master",
"social_messages_web"
)
foreach ($coreName in $sitecoreCores) {
Write-Output "Creating $coreName index"
New-Item "..\wwwroot\server\solr\" -Name "$coreName" -ItemType "directory"
New-Item "..\wwwroot\server\solr\$coreName" -Name "data" -ItemType "directory"
xcopy "..\wwwroot\server\solr\configsets\sitecore\conf\*" "..\wwwroot\server\solr\$coreName\conf\*" /S /Y
New-Item "..\wwwroot\server\solr\$coreName\core.properties"
Set-Content "..\wwwroot\server\solr\$coreName\core.properties" "name=$coreName`r`nupdate.autoCreateFields=false`r`ndataDir=data"
}
$xdbCores = @(
"xdb",
"xdb_rebuild"
)
foreach ($coreName in $xdbCores) {
Write-Output "Creating $coreName index"
New-Item "..\wwwroot\server\solr\" -Name "$coreName" -ItemType "directory"
New-Item "..\wwwroot\server\solr\$coreName" -Name "data" -ItemType "directory"
if ($usingDefault) {
xcopy "..\wwwroot\server\solr\configsets\_default\conf\*" "..\wwwroot\server\solr\$coreName\conf\*" /S /Y
}
else {
xcopy "..\wwwroot\server\solr\configsets\basic_configs\conf\*" "..\wwwroot\server\solr\$coreName\conf\*" /S /Y
}
New-Item "..\wwwroot\server\solr\$coreName\core.properties"
Set-Content "..\wwwroot\server\solr\$coreName\core.properties" "name=$coreName`r`ndataDir=data"
}