forked from chocolatey/choco-quickstart-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This script adds parameterization to the ClientSetup.ps1 script that is hosted within the Nexus repository. It also adds parameterization to the registration script that is executed on a client so you can customize the installation.
- Loading branch information
1 parent
7865b78
commit 8ceddd5
Showing
2 changed files
with
255 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,104 @@ | ||
# Here is a script you can run to setup your endpoints to connect to the C4B Server. | ||
# This includes: | ||
# - Installing Chocolatey | ||
# - Installing your chocolatey-license | ||
# - Running the Client Setup, which sets up Nexus repo and CCM acccess | ||
[CmdletBinding()] | ||
Param( | ||
# The DNS name of the server that hosts your repository, Jenkins, and Chocolatey Central Management | ||
[Parameter()] | ||
[String] | ||
$Fqdn = '{{ FQDN }}', | ||
|
||
$HostName = {{hostname}} #This needs to be the same hostname as the CN/Subject of your SSL cert | ||
# Client salt value used to populate the centralManagementClientCommunicationSaltAdditivePassword | ||
# value in the Chocolatey config file | ||
[Parameter()] | ||
[String] | ||
$ClientCommunicationSalt = '{{ ClientSaltValue }}', | ||
|
||
# placeholder if using a self-signed cert | ||
# Server salt value used to populate the centralManagementServiceCommunicationSaltAdditivePassword | ||
# value in the Chocolatey config file | ||
[Parameter()] | ||
[String] | ||
$ServiceCommunicationSalt = '{{ ServiceSaltValue }}', | ||
|
||
$downloader = New-Object -TypeName System.Net.WebClient | ||
Invoke-Expression ($downloader.DownloadString("https://$($HostName):8443/repository/choco-install/ClientSetup.ps1")) | ||
[Parameter(Mandatory)] | ||
[PSCredential] | ||
$RepositoryCredential, | ||
|
||
# The URL of a proxy server to use for connecting to the repository. | ||
[Parameter()] | ||
[String] | ||
$ProxyUrl, | ||
# The credentials, if required, to connect to the proxy server. | ||
[Parameter()] | ||
[PSCredential] | ||
$ProxyCredential, | ||
|
||
# Allows for the application of user-defined configuration that is applied after the base configuration. | ||
# Can override base configuration with this parameter | ||
[Parameter()] | ||
[Hashtable[]] | ||
$AdditionalConfiguration, | ||
|
||
# Allows for the toggling of additonal features that is applied after the base configuration. | ||
# Can override base configuration with this parameter | ||
[Parameter()] | ||
[Hashtable[]] | ||
$AdditionalFeatures, | ||
|
||
# Allows for the installation of additional packages after the system base packages have been installed. | ||
[Parameter()] | ||
[Hashtable[]] | ||
$AdditionalPackages, | ||
|
||
# Allows for the addition of alternative sources after the base conifguration has been applied. | ||
# Can override base configuration with this parameter | ||
[Parameter()] | ||
[Hashtable[]] | ||
$AdditionalSources | ||
) | ||
|
||
# Touch NOTHING below this line | ||
$RepositoryUrl = "https://$($fqdn):8443/repository/ChocolateyInternal/index.json" | ||
|
||
#Initialize params hashtable so we can add to it if needed later | ||
$params = @{ | ||
Credential = $RepositoryCredential | ||
ClientSalt = $ClientCommunicationSalt | ||
ServiceSalt = $ServiceCommunicationSalt | ||
RepositoryUrl = $RepositoryUrl | ||
} | ||
|
||
switch ($true) { | ||
$PSBoundParameters.ContainsKey('AdditionalConfiguration') { | ||
$params.Add('AdditionalConfiguration', $AdditionalConfiguration) | ||
} | ||
$PSBoundParameters.ContainsKey('AdditionalFeatures') { | ||
$params.add('AdditionalFeatures', $AdditionalFeatures) | ||
} | ||
|
||
$PSBoundParameters.ContainsKey('AdditionalPackages') { | ||
$params.Add('AdditionalPackages', $AdditionalPackages) | ||
} | ||
|
||
$PSBoundParameters.ContainsKey('AdditionalSources') { | ||
$params.Add('AdditionalSources', $AdditionalSources) | ||
} | ||
} | ||
|
||
$downloader = [System.Net.WebClient]::new() | ||
|
||
#setup proxy if required | ||
if ($ProxyUrl) { | ||
$params.add('ProxyUrl', $ProxyUrl) | ||
$proxy = [System.Net.WebProxy]::new($ProxyUrl, $true <#bypass on local#>) | ||
|
||
if ($ProxyCredential) { | ||
$params.Add('ProxyCredential', $ProxyCredential) | ||
$proxy.Credentials = $ProxyCredential | ||
} | ||
|
||
$downloader.Proxy = $proxy | ||
} | ||
|
||
$downloader.Credentials = $RepositoryCredential | ||
|
||
$script = $downloader.DownloadString("https://$($FQDN):8443/repository/choco-install/ClientSetup.ps1") | ||
|
||
& ([scriptblock]::Create($script)) @params |