This repository has been archived by the owner on Aug 5, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSetup-Environment.ps1
114 lines (96 loc) · 3.3 KB
/
Setup-Environment.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
param (
[Parameter()]
[string]
$scVersion = "9.3.0", #Only supported version currently
[ValidateSet("xm", "xp", "xc")]
[string]
$scVariant = "xp",
#[switch]
[bool]
$includeSPE = $true
)
$ErrorActionPreference = "stop"
$activeScVariant = $scVariant
if ($includeSPE) {
$activeScVariant += ".spe"
}
## VARIABLES
$dockerProcess = "com.docker.service"
$scVersionX = $scVersion.Substring(0,4) + "x";
$ghuc = "https://raw.githubusercontent.com/Sitecore/docker-images/master/"
#TODOD: Change
$ghucSc = "$($ghuc)windows/tests/$scVersionX/"
$filesToDownload = @(
@{src = "$($ghucSc)docker-compose.$activeScVariant.yml"; dst = "docker-compose.yml" }
@{src = "$($ghucSc).env"; dst = ".env" ; skip = $true }
@{src = "$($ghucSc)Clean-Data.ps1"; dst = "Clean-Data.ps1" }
@{src = "$($ghuc)Set-LicenseEnvironmentVariable.ps1"; dst = "Set-LicenseEnvironmentVariable.ps1" }
)
## Data folder creation
$foldersToCreate = @(
@{src = "./data/cd/" },
@{src = "./data/cm/" }
@{src = "./data/commerce-authoring/" }
@{src = "./data/commerce-minions/" }
@{src = "./data/commerce-ops/" }
@{src = "./data/commerce-shops/" }
@{src = "./data/creativeexchange/" }
@{src = "./data/identity/" }
@{src = "./data/solr/" }
@{src = "./data/sql/" }
@{src = "./data/xconnect-automationengine/" }
@{src = "./data/xconnect-indexworker" }
@{src = "./data/xconnect-processingengine/" }
@{src = "./data/xconnect/" }
@{src = "./src/" }
)
$foldersToCreate | ForEach-Object {
New-Item -path $_.src -ItemType Directory -ErrorAction Ignore
}
$envFile = ".env";
## SETUP
$filesToDownload | ForEach-Object {
#Add filecheck
if ($_.skip -eq $true) {
if (!( Test-Path $_.dst)) {
Write-Host "Dowloading $($_.src)"
Invoke-WebRequest $_.src -UseBasicParsing -OutFile $_.dst
}
}
else {
Write-Host "Dowloading $($_.src)"
Invoke-WebRequest $_.src -UseBasicParsing -OutFile $_.dst
}
}
## CONFIGURE ENVIRONMENT
if (!((get-content $envFile) -match "REGISTRY=[a-z]+")) {
$registery = Read-Host "What is your Azure Registry?:"
((get-content $envFile ) -replace "REGISTRY=", "REGISTRY=$registery") | set-content $envFile
}
if (!((get-content $envFile) -match "SITECORE_VERSION=[0-9.]+")) {
((get-content $envFile ) -replace "SITECORE_VERSION=", "SITECORE_VERSION=$scVersion") | set-content $envFile
}
if ($null -eq $Env:SITECORE_LICENSE ) {
$scLicensePath = Get-File -description "Where is your Sitecore license located?" "Sitecore XML |license.xml"
.\Set-LicenseEnvironmentVariable.ps1 $scLicensePath -PersistForCurrentUser
}
# Run
if ($null -ne (Get-Process $dockerProcess -ErrorAction Ignore)) {
docker login
docker-compose pull
docker-compose up
}
else {
Write-Error "Could not start docker-compose, did you install & start docker?"
}
Function Get-File($initialDirectory, $description, $filter) {
[void] [System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms')
$dialog = New-Object System.Windows.Forms.OpenFileDialog -Property @{
Title = $description
InitialDirectory = $initialDirectory
Filter = $filter
FilterIndex = 1
}
[void] $dialog.ShowDialog()
return $dialog.FileNames
}