forked from Sitecore/docker-images
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_Prepare.ps1
54 lines (44 loc) · 1.38 KB
/
_Prepare.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
param(
[Parameter(Mandatory=$true)]
[int]
$sitecoreVersion
)
$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';
Write-Host "Sitecore version is $sitecoreVersion"
if ($sitecoreVersion -lt 930) {
Write-Warning "Sitecore version is prior to 9.3.0 means C:\license\license.xml file is to be created"
try
{
$gzipBytes = [System.Convert]::FromBase64String($env:SITECORE_LICENSE)
$memory = [System.IO.MemoryStream]::new($gzipBytes)
$licenseFileStream = [System.IO.Compression.GZipStream]::new($memory, [System.IO.Compression.CompressionMode]::Decompress)
$reader = [System.IO.StreamReader]::new($licenseFileStream)
$licenseText = $reader.ReadToEnd();
$licenseFileStream.Close()
if (-not (Test-Path "C:\license")) {
MKDIR "C:\license" | Out-Null
}
[System.IO.File]::WriteAllText("C:\license\license.xml", $licenseText)
}
finally
{
# cleanup
if ($null -ne $reader)
{
$reader.Dispose()
$reader = $null
}
if ($null -ne $gzip)
{
$gzip.Dispose()
$gzip = $null
}
if ($null -ne $memory)
{
$memory.Dispose()
$memory = $null
}
$licenseFileStream = $null
}
}
$env:REGISTRY = "$env:REGISTRY".TrimEnd('/') + "/";