|
1 | 1 | package provisionersdk
|
2 | 2 |
|
3 | 3 | import (
|
| 4 | + _ "embed" |
4 | 5 | "fmt"
|
5 | 6 | "strings"
|
6 | 7 | )
|
7 | 8 |
|
8 | 9 | var (
|
9 |
| - // On Windows, VS Code Remote requires a parent process of the |
10 |
| - // executing shell to be named "sshd", otherwise it fails. See: |
11 |
| - // https://github.com/microsoft/vscode-remote-release/issues/5699 |
12 |
| - windowsScript = `$ProgressPreference = "SilentlyContinue" |
13 |
| -Invoke-WebRequest -Uri ${ACCESS_URL}bin/coder-windows-${ARCH}.exe -OutFile $env:TEMP\sshd.exe |
14 |
| -Set-MpPreference -DisableRealtimeMonitoring $true -ExclusionPath $env:TEMP\sshd.exe |
15 |
| -$env:CODER_AGENT_AUTH = "${AUTH_TYPE}" |
16 |
| -$env:CODER_AGENT_URL = "${ACCESS_URL}" |
17 |
| -Start-Process -FilePath $env:TEMP\sshd.exe -ArgumentList "agent" -PassThru` |
18 |
| - |
19 |
| - linuxScript = `#!/usr/bin/env sh |
20 |
| -set -eux pipefail |
21 |
| -BINARY_DIR=$(mktemp -d -t coder.XXXXXX) |
22 |
| -BINARY_NAME=coder |
23 |
| -BINARY_URL=${ACCESS_URL}bin/coder-linux-${ARCH} |
24 |
| -cd $BINARY_DIR |
25 |
| -if command -v curl >/dev/null 2>&1; then |
26 |
| - curl -fsSL --compressed "${BINARY_URL}" -o "${BINARY_NAME}" |
27 |
| -elif command -v wget >/dev/null 2>&1; then |
28 |
| - wget -q "${BINARY_URL}" -O "${BINARY_NAME}" |
29 |
| -elif command -v busybox >/dev/null 2>&1; then |
30 |
| - busybox wget -q "${BINARY_URL}" -O "${BINARY_NAME}" |
31 |
| -else |
32 |
| - echo "error: no download tool found, please install curl, wget or busybox wget" |
33 |
| - exit 1 |
34 |
| -fi |
35 |
| -chmod +x $BINARY_NAME |
36 |
| -export CODER_AGENT_AUTH="${AUTH_TYPE}" |
37 |
| -export CODER_AGENT_URL="${ACCESS_URL}" |
38 |
| -exec ./$BINARY_NAME agent` |
39 |
| - |
40 |
| - darwinScript = `#!/usr/bin/env sh |
41 |
| -set -eux pipefail |
42 |
| -BINARY_DIR=$(mktemp -d -t coder.XXXXXX) |
43 |
| -BINARY_NAME=coder |
44 |
| -cd $BINARY_DIR |
45 |
| -curl -fsSL --compressed "${ACCESS_URL}bin/coder-darwin-${ARCH}" -o "${BINARY_NAME}" |
46 |
| -chmod +x $BINARY_NAME |
47 |
| -export CODER_AGENT_AUTH="${AUTH_TYPE}" |
48 |
| -export CODER_AGENT_URL="${ACCESS_URL}" |
49 |
| -exec ./$BINARY_NAME agent` |
| 10 | + // These used to be hard-coded, but after growing significantly more complex |
| 11 | + // it made sense to put them in their own files (e.g. for linting). |
| 12 | + //go:embed scripts/bootstrap_windows.ps1 |
| 13 | + windowsScript string |
| 14 | + //go:embed scripts/bootstrap_linux.sh |
| 15 | + linuxScript string |
| 16 | + //go:embed scripts/bootstrap_darwin.sh |
| 17 | + darwinScript string |
50 | 18 |
|
51 | 19 | // A mapping of operating-system ($GOOS) to architecture ($GOARCH)
|
52 | 20 | // to agent install and run script. ${DOWNLOAD_URL} is replaced
|
|
0 commit comments