Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit35073eb

Browse files
committed
Update bootstrap scripts to check for executable correctness
Signed-off-by: Danny Kopping <danny@coder.com>
1 parentf149279 commit35073eb

File tree

3 files changed

+35
-4
lines changed

3 files changed

+35
-4
lines changed

‎provisionersdk/scripts/bootstrap_darwin.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -eux
44
# This is to allow folks to exec into a failed workspace and poke around to
55
# troubleshoot.
66
waitonexit() {
7-
echo"=== Agent script exited with non-zero code. Sleeping 24h to preserve logs..."
7+
echo"=== Agent script exited with non-zero code ($?). Sleeping 24h to preserve logs..."
88
sleep 86400
99
}
1010
trap waitonexit EXIT
@@ -31,4 +31,13 @@ fi
3131

3232
export CODER_AGENT_AUTH="${AUTH_TYPE}"
3333
export CODER_AGENT_URL="${ACCESS_URL}"
34-
exec ./$BINARY_NAME agent
34+
35+
output=$(./${BINARY_NAME} --version| head -n1)
36+
echo"${output}"| grep -q Coder
37+
if [$?-ne 0 ];then
38+
echo>&2"ERROR: Downloaded agent binary is invalid"
39+
echo>&2"Script output: '${output}'"
40+
exit 2
41+
fi
42+
43+
exec ./${BINARY_NAME} agent

‎provisionersdk/scripts/bootstrap_linux.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -eux
44
# This is to allow folks to exec into a failed workspace and poke around to
55
# troubleshoot.
66
waitonexit() {
7-
echo"=== Agent script exited with non-zero code. Sleeping 24h to preserve logs..."
7+
echo"=== Agent script exited with non-zero code ($?). Sleeping 24h to preserve logs..."
88
sleep 86400
99
}
1010
trap waitonexit EXIT
@@ -86,4 +86,13 @@ fi
8686

8787
export CODER_AGENT_AUTH="${AUTH_TYPE}"
8888
export CODER_AGENT_URL="${ACCESS_URL}"
89-
exec ./$BINARY_NAME agent
89+
90+
output=$(./${BINARY_NAME} --version| head -n1)
91+
echo"${output}"| grep -q Coder
92+
if [$?-ne 0 ];then
93+
echo>&2"ERROR: Downloaded agent binary is invalid"
94+
echo>&2"Script output: '${output}'"
95+
exit 2
96+
fi
97+
98+
exec ./${BINARY_NAME} agent

‎provisionersdk/scripts/bootstrap_windows.ps1

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,19 @@ if (-not (Get-Command 'Set-MpPreference' -ErrorAction SilentlyContinue)) {
3535
$env:CODER_AGENT_AUTH="${AUTH_TYPE}"
3636
$env:CODER_AGENT_URL="${ACCESS_URL}"
3737

38+
$psi= [System.Diagnostics.ProcessStartInfo]::new("$env:TEMP\sshd.exe",'--version')
39+
$psi.UseShellExecute=$false
40+
$psi.RedirectStandardOutput=$true
41+
$p= [System.Diagnostics.Process]::Start($psi)
42+
$output=$p.StandardOutput.ReadToEnd()
43+
$p.WaitForExit()
44+
45+
if ($output-notlike"*Coder*") {
46+
Write-Error"ERROR: Downloaded agent binary is invalid"
47+
Write-Error"Script output: '$output'"
48+
Exit2
49+
}
50+
3851
# Check if we're running inside a Windows container!
3952
$inContainer=$false
4053
if ((Get-ItemProperty'HKLM:\SYSTEM\CurrentControlSet\Control'-Name'ContainerType'-ErrorAction SilentlyContinue)-ne$null) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp