1 # Licensed to the .NET Foundation under one or more agreements.
2 # The .NET Foundation licenses this file to you under the MIT license.
3 # See the LICENSE file in the project root for more information.
4
5 . .\config.ps1
6
7 # The following variable names should match the ones read by Configuration.*.cs code.
8 $script:ClientConfiguration = @(
9
10 # Configuration.Http:
11 @{Name = "COREFX_HTTPHOST"; Value = $script:iisServerFQDN},
12 @{Name = "COREFX_SECUREHTTPHOST"; Value = $script:iisServerFQDN},
13 @{Name = "COREFX_HTTP2HOST"; Value = $script:iisServerFQDN}, # Requires Windows 10 and above.
14 @{Name = "COREFX_DOMAINJOINED_HTTPHOST"; Value = $script:iisServerFQDN},
15 @{Name = "COREFX_DOMAINJOINED_PROXYHOST"; Value = $null},
16 @{Name = "COREFX_DOMAINJOINED_PROXYPORT"; Value = $null},
17 @{Name = "COREFX_HTTPHOST_SSL2"; Value = $null},
18 @{Name = "COREFX_HTTPHOST_SSL3"; Value = $null},
19 @{Name = "COREFX_HTTPHOST_TLS10"; Value = $null},
20 @{Name = "COREFX_HTTPHOST_TLS11"; Value = $null},
21 @{Name = "COREFX_HTTPHOST_TLS12"; Value = $null},
22 @{Name = "COREFX_HTTPHOST_EXPIREDCERT"; Value = $null},
23 @{Name = "COREFX_HTTPHOST_WRONGHOSTNAME"; Value = $null},
24 @{Name = "COREFX_HTTPHOST_SELFSIGNEDCERT"; Value = $null},
25 @{Name = "COREFX_HTTPHOST_REVOKEDCERT"; Value = $null},
26 @{Name = "COREFX_STRESS_HTTP"; Value = "1"},
27
28 # Configuration.WebSockets:
29 @{Name = "COREFX_WEBSOCKETHOST"; Value = $script:iisServerFQDN},
30 @{Name = "COREFX_SECUREWEBSOCKETHOST"; Value = $script:iisServerFQDN},
31
32 # Configuration.Security:
33 @{Name = "COREFX_NET_AD_DOMAINNAME"; Value = $script:domainNetbios},
34 @{Name = "COREFX_NET_AD_USERNAME"; Value = $script:domainUserName},
35 @{Name = "COREFX_NET_AD_PASSWORD"; Value = $script:domainUserPassword},
36 @{Name = "COREFX_NET_SECURITY_NEGOSERVERURI"; Value = "http://$($script:iisServerFQDN)"},
37 @{Name = "COREFX_NET_SECURITY_TLSSERVERURI"; Value = "https://$($script:iisServerFQDN)"},
38
39 @{Name = "COREFX_NET_SOCKETS_SERVERURI"; Value = "http://$($script:iisServerFQDN)"}
40 )
41
GetRoleForMachine($machineName)42 Function GetRoleForMachine($machineName)
43 {
44 return $script:Roles | where {$_.MachineName.ToUpper() -eq $machineName.ToUpper()}
45 }
46
GetPreRebootRoleForMachine($machineName)47 Function GetPreRebootRoleForMachine($machineName)
48 {
49 return $script:PreRebootRoles | where {$_.MachineName.ToUpper() -eq $machineName.ToUpper()}
50 }
51
GetRole($roleName)52 Function GetRole($roleName)
53 {
54 return $script:Roles | where {$_.Name.ToUpper() -eq $roleName.ToUpper()}
55 }
56
CheckPreRebootMachineInfonull57 Function CheckPreRebootMachineInfo
58 {
59 $role = GetPreRebootRoleForMachine $Env:COMPUTERNAME
60
61 if ($role.Name -ne $script:COREFX_ROLE_NAME)
62 {
63 throw "This script needs to run on machines part of the $($role.Name) role."
64 }
65
66 if ((-not [string]::IsNullOrWhiteSpace($role.MachineIP)) -and ((Get-NetIPAddress | where {$_.IPAddress -eq $role.MachineIP}).Count -eq 0))
67 {
68 throw "The current machine doesn't have the expected Static IP address: $($role.MachineIP)"
69 }
70 }
71
CheckMachineInfo()72 Function CheckMachineInfo
73 {
74 $role = GetRoleForMachine $Env:COMPUTERNAME
75
76 if ($role.Name -ne $script:COREFX_ROLE_NAME)
77 {
78 throw "This script needs to run on machines part of the $($role.Name) role."
79 }
80
81 if ((-not [string]::IsNullOrWhiteSpace($role.MachineIP)) -and ((Get-NetIPAddress | where {$_.IPAddress -eq $role.MachineIP}).Count -eq 0))
82 {
83 throw "The current machine doesn't have the expected Static IP address: $($role.MachineIP)"
84 }
85 }
86
EnvironmentAddRoleStatus($status)87 Function EnvironmentAddRoleStatus($status)
88 {
89 [Environment]::SetEnvironmentVariable($script:COREFX_ROLE_NAME, $status, "Machine")
90 }
91
EnvironmentSetInstalledRoleStatus()92 Function EnvironmentSetInstalledRoleStatus
93 {
94 EnvironmentAddRoleStatus "Installed"
95 }
96
EnvironmentSetRebootPendingRoleStatusnull97 Function EnvironmentSetRebootPendingRoleStatus
98 {
99 EnvironmentAddRoleStatus "PendingReboot"
100 }
101
EnvironmentRemoveRoleStatus()102 Function EnvironmentRemoveRoleStatus
103 {
104 [Environment]::SetEnvironmentVariable($script:COREFX_ROLE_NAME, $null, "Machine")
105 }
106
EnvironmentCheckUninstallRoleStatus()107 Function EnvironmentCheckUninstallRoleStatus
108 {
109 if ([Environment]::GetEnvironmentVariable($script:COREFX_ROLE_NAME, "Machine") -ne "Installed")
110 {
111 Write-Warning "The machine doesn't appear to be in the $($script:COREFX_ROLE_NAME) role."
112 $continue = Read-Host "Do you want to continue? [Y/N]"
113 if ($continue.ToUpper() -ne "Y")
114 {
115 Write-Warning "Aborted by user."
116 exit
117 }
118 }
119 }
120
EnvironmentIsRoleRebootPending()121 Function EnvironmentIsRoleRebootPending
122 {
123 return [Environment]::GetEnvironmentVariable($script:COREFX_ROLE_NAME, "Machine") -eq "PendingReboot"
124 }
125
EnvironmentIsRoleInstalled()126 Function EnvironmentIsRoleInstalled
127 {
128 return [Environment]::GetEnvironmentVariable($script:COREFX_ROLE_NAME, "Machine") -eq "Installed"
129 }
130
DownloadFile($source, $destination)131 Function DownloadFile($source, $destination)
132 {
133 # BITS remoting doesn't work on systems <= TH2.
134 if ([System.Environment]::OSVersion.Version -gt (new-object 'Version' 10,0,10586,0))
135 {
136 Start-BitsTransfer -Source $source -Destination $destination
137 }
138 else
139 {
140 # BUG: taking very long: Invoke-WebRequest $source -OutFile $destination
141 $fqDestination = Join-Path (pwd) $destination
142 $wc = New-Object System.Net.WebClient
143 $wc.Downloadfile($source, $fqDestination.ToString())
144 }
145 }
146
GetIISCodePathnull147 Function GetIISCodePath
148 {
149 return ".\IISApplications"
150 }
151