Skip to content

Commit 4cf5046

Browse files
Merge pull request #233 from chocolatey/RemoveChocolateyInstallScript
(#223) Removes Chocolatey Install Script from Repository
2 parents e91de35 + 5c7344f commit 4cf5046

File tree

3 files changed

+22
-774
lines changed

3 files changed

+22
-774
lines changed

Set-SslSecurity.ps1

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,9 @@ process {
7777
Start-Transcript -Path "$env:SystemDrive\choco-setup\logs\Set-SslCertificate-$(Get-Date -Format 'yyyyMMdd-HHmmss').txt"
7878

7979
# Dot-source helper functions
80-
. .\scripts\Get-Helpers.ps1
81-
#Collect current certificate configuration
80+
$ScriptDir = Join-Path $PSScriptRoot "scripts"
81+
. $ScriptDir\Get-Helpers.ps1
82+
# Collect current certificate configuration
8283
$Certificate = if ($Subject) {
8384
Get-Certificate -Subject $Subject
8485
}
@@ -138,14 +139,6 @@ process {
138139
# Connect to Nexus
139140
Connect-NexusServer -Hostname $SubjectWithoutCn -Credential $Credential -UseSSL
140141

141-
# Add updated scripts to raw repo in Nexus
142-
143-
# Push ChocolateyInstall.ps1 to raw repo
144-
$ScriptDir = "$env:SystemDrive\choco-setup\files\scripts"
145-
$ChocoInstallScript = "$ScriptDir\ChocolateyInstall.ps1"
146-
(Get-Content -Path $ChocoInstallScript) -replace "{{hostname}}", $SubjectWithoutCn | Set-Content -Path $ChocoInstallScript
147-
New-NexusRawComponent -RepositoryName 'choco-install' -File "$ChocoInstallScript"
148-
149142
# Push ClientSetup.ps1 to raw repo
150143
$ClientScript = "$ScriptDir\ClientSetup.ps1"
151144
(Get-Content -Path $ClientScript) -replace "{{hostname}}", $SubjectWithoutCn | Set-Content -Path $ClientScript
@@ -288,7 +281,7 @@ process {
288281

289282
$ScriptBlock | Set-Content -Path $EndpointScript
290283

291-
#Agent Setup
284+
# Agent Setup
292285
$agentArgs = @{
293286
CentralManagementServiceUrl = "https://$($SubjectWithoutCn):24020/ChocolateyManagementService"
294287
ServiceSalt = $ServiceSaltValue
@@ -300,14 +293,14 @@ process {
300293

301294
else {
302295

303-
#Agent Setup
296+
# Agent Setup
304297
$agentArgs = @{
305298
CentralManagementServiceUrl = "https://$($SubjectWithoutCn):24020/ChocolateyManagementService"
306299
}
307300

308301
Install-ChocolateyAgent @agentArgs
309302

310-
#Register endpoint script
303+
# Register endpoint script
311304
(Get-Content -Path $EndpointScript) -replace "{{hostname}}", "'$SubjectWithoutCn'" | Set-Content -Path $EndpointScript
312305
if ($IsSelfSigned) {
313306
$ScriptBlock = @"

Start-C4bNexusSetup.ps1

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,22 @@ process {
7171
# Temporary workaround to reset the NuGet v3 cache, such that it doesn't capture localhost as the FQDN
7272
Remove-NexusRepositoryFolder -RepositoryName ChocolateyInternal -Name v3
7373

74+
# Push latest ChocolateyInstall.ps1 to raw repo
75+
$ScriptDir = "$env:SystemDrive\choco-setup\files\scripts"
76+
$ChocoInstallScript = "$ScriptDir\ChocolateyInstall.ps1"
77+
78+
if (-not (Test-Path $ChocoInstallScript)) {
79+
Invoke-WebRequest -Uri 'https://chocolatey.org/install.ps1' -OutFile $ChocoInstallScript
80+
}
81+
82+
$Signature = Get-AuthenticodeSignature -FilePath $ChocoInstallScript
83+
84+
if ($Signature.Status -eq 'Valid' -and $Signature.SignerCertificate.Subject -eq 'CN="Chocolatey Software, Inc.", O="Chocolatey Software, Inc.", L=Topeka, S=Kansas, C=US') {
85+
New-NexusRawComponent -RepositoryName 'choco-install' -File $ChocoInstallScript
86+
} else {
87+
Write-Error "ChocolateyInstall.ps1 script signature is not valid. Please investigate."
88+
}
89+
7490
# Add ChocolateyInternal as a source repository
7591
choco source add -n 'ChocolateyInternal' -s "$((Get-NexusRepository -Name 'ChocolateyInternal').url)/index.json" --priority 1
7692

0 commit comments

Comments
 (0)