-
Notifications
You must be signed in to change notification settings - Fork 8
/
solr.ps1
99 lines (79 loc) · 2.91 KB
/
solr.ps1
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
<#
The solr.json config perform the followin tasks:
- if 'UseLocalFiles' is set to false then script will Download JRE and Solr 6.6.2
(check parameters 'JREDownloadUrl' and 'JREInstaller')
- if 'UseLocalFiles' is set to true script will look in LocalStorage for 'JREInstaller' and 'SolrPackage'
- install JRE
- install Solr
- create certificates for domain 'CertificateName'
- setup SSL for Solr
- install Solr as a Windows Service
#>
param (
[string]$SolrVersion = "6.6.2",
[string]$SolrHost = "solr.local",
[string]$SolrPort = "8983",
[string]$SolrMemory = "1024m",
[string]$SolrService = "SolrService-$SolrHost-$SolrPort",
[string]$SolrInstallFolder = "C:\solr", # internally in 'solr.json', installation path is build like $SolrInstallFolder\solr-parameter('SolrVersion')
[boolean]$SSL = $true,
[boolean]$UnInstall = $false
)
if( -not $UnInstall )
{
# verify if port and host are free
$service = Get-Service -Name $SolrService -ErrorAction SilentlyContinue
if( $service -ne $null )
{
Write-Error "Service $SolrService is already running."
}
try
{
$uri = "http://$($SolrHost):$SolrPort/solr/"
$response = Invoke-WebRequest -Uri $uri -ErrorAction SilentlyContinue
Write-Error "Host and port $uri is already used."
}
catch{}
}
# Do not display progress (performance improvement)
$global:ProgressPreference = 'silentlyContinue'
$LocalStorage = "$PSScriptRoot\Storage"
# Comment out this if you have own solr.json
$GitHubRoot = "https://raw.githubusercontent.com/SoftServeInc/SitecoreInstallExtensions/master/Configuration/"
if( -not (Test-Path "$PSScriptRoot\Solr.json" ) )
{
Invoke-WebRequest -Uri "$GitHubRoot/Solr.json" -OutFile "$PSScriptRoot\Solr.json"
}
else
{
Write-Verbose "File $PSScriptRoot\Solr.json already exists."
}
$installSolr =@{
Path = "$PSScriptRoot\Solr.json"
LocalStorage = "$LocalStorage"
SolrVersion = $SolrVersion
SolrHost = $SolrHost
SolrPort = $SolrPort
SolrMemory = $SolrMemory
SolrUseSSL = $SSL
SolrServiceName = $SolrService
InstallFolder = $SolrInstallFolder
# For SSL certificate generation
CertificateName = $SolrHost
# For SSL certificate export
Property = "Subject"
Value = "CN=$SolrHost"
# if you want to download JRE and Solr check JREDownloadUrl and SolrDownloadUrl in solr.json
# and switch to $false
UseLocalFiles = $false
UnInstallSolr = $UnInstall
}
Install-SitecoreConfiguration @installSolr -Verbose
if( -not $UnInstall )
{
$installSolr | ConvertTo-JSON | Set-Content -Path "$SolrInstallFolder\$SolrHost-$SolrVersion.installation.params"
}
# When you install Solr on VM in a AWS, Azure or GCP probably you have to create a firewall
# rule to get access from remote computer.
#
# New-NetFirewallRule -LocalPort $SolrPort -DisplayName "Allow-Solr" -Direction Inbound -Protocol TCP -Action Allow