Skip to content

feat: support windows containers in bootstrap script #12662

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions provisionersdk/scripts/bootstrap_windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,24 @@ while ($true) {
}
}

# If the below fails, retrying probably will not help.
Set-MpPreference -DisableRealtimeMonitoring $true -ExclusionPath $env:TEMP\sshd.exe
# Check if running in a Windows container
if (-not (Get-Command 'Set-MpPreference' -ErrorAction SilentlyContinue)) {
Write-Output "Set-MpPreference not available, skipping..."
} else {
Set-MpPreference -DisableRealtimeMonitoring $true -ExclusionPath $env:TEMP\sshd.exe
}

$env:CODER_AGENT_AUTH = "${AUTH_TYPE}"
$env:CODER_AGENT_URL = "${ACCESS_URL}"
Start-Process -FilePath $env:TEMP\sshd.exe -ArgumentList "agent" -PassThru

# Check if we're running inside a Windows container!
$inContainer = $false
if ((Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control' -Name 'ContainerType' -ErrorAction SilentlyContinue) -ne $null) {
$inContainer = $true
}
if ($inContainer) {
# If we're in a container, run in a the foreground!
Start-Process -FilePath $env:TEMP\sshd.exe -ArgumentList "agent" -Wait -NoNewWindow
} else {
Start-Process -FilePath $env:TEMP\sshd.exe -ArgumentList "agent" -PassThru
}