Skip to content

Commit

Permalink
Merge pull request #105 from luthermonson/proc-paths
Browse files Browse the repository at this point in the history
adding process whiteList config to installer
  • Loading branch information
luthermonson authored Apr 21, 2022
2 parents 165be2f + 19ef2b4 commit d9cae19
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,9 @@ function Invoke-WinsInstaller {
New-Item -Path $env:CATTLE_AGENT_CONFIG_DIR -ItemType Directory -Force | Out-Null
}

# copy powershell for wins
Copy-Item $($(Get-Command powershell).Source) "$env:CATTLE_AGENT_CONFIG_DIR/powershell.exe"

if (-Not $env:CATTLE_AGENT_VAR_DIR) {
$env:CATTLE_AGENT_VAR_DIR = "C:/var/lib/rancher/agent"
Write-LogInfo "Using default agent var directory $( $env:CATTLE_AGENT_VAR_DIR )"
Expand Down Expand Up @@ -307,7 +310,7 @@ function Invoke-WinsInstaller {

if ($env:CATTLE_AGENT_BINARY_LOCAL -eq "true") {
Write-LogInfo "Using local Wins installer from $($env:CATTLE_AGENT_BINARY_LOCAL_LOCATION)"
Copy-Item -Path $env:CATTLE_AGENT_BINARY_LOCAL -Destination "$env:CATTLE_AGENT_BIN_PREFIX/bin/wins.exe"
Copy-Item -Path $env:CATTLE_AGENT_BINARY_LOCAL_LOCATION -Destination "$env:CATTLE_AGENT_BIN_PREFIX/bin/wins.exe"
}
else {
Write-LogInfo "Downloading Wins from $($env:CATTLE_AGENT_BINARY_URL)"
Expand Down Expand Up @@ -454,6 +457,20 @@ function Invoke-WinsInstaller {
}

function Set-WinsConfig() {

$winsConfig =
@"
whiteList:
processPaths:
- $($env:CATTLE_AGENT_CONFIG_DIR)/powershell.exe
- $($env:CATTLE_AGENT_CONFIG_DIR)/wins-upgrade.exe
- C:/etc/wmi-exporter/wmi-exporter.exe
- C:/etc/windows-exporter/windows-exporter.exe
proxyPorts:
- 9796
"@
Set-Content -Path $env:CATTLE_AGENT_CONFIG_DIR/config -Value $winsConfig

$agentConfig =
@"
systemagent:
Expand All @@ -462,7 +479,7 @@ systemagent:
remoteEnabled: $($env:CATTLE_REMOTE_ENABLED)
preserveWorkDirectory: $($env:CATTLE_PRESERVE_WORKDIR)
"@
Set-Content -Path $env:CATTLE_AGENT_CONFIG_DIR/config -Value $agentConfig
Add-Content -Path $env:CATTLE_AGENT_CONFIG_DIR/config -Value $agentConfig
if ($env:CATTLE_REMOTE_ENABLED -eq "true") {
Add-Content -Path $env:CATTLE_AGENT_CONFIG_DIR/config -Value " connectionInfoFile: $env:CATTLE_AGENT_VAR_DIR/rancher2_connection_info.json"
}
Expand Down Expand Up @@ -571,10 +588,10 @@ csi-proxy:
foreach ($feature in $RequiredFeatures) {
$f = Get-WindowsFeature -Name $feature
if (-not $f.Installed) {
Write-FatalLog "Windows feature: '$feature' is not installed. Please run: Install-WindowsFeature -Name $feature"
Write-LogFatal "Windows feature: '$feature' is not installed. Please run: Install-WindowsFeature -Name $feature"
}
else {
Write-InfoLog "Windows feature: '$feature' is installed. Installation will proceed."
Write-LogInfo "Windows feature: '$feature' is installed. Installation will proceed."
}
}
}
Expand Down

0 comments on commit d9cae19

Please sign in to comment.