|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +set -euo pipefail |
| 4 | + |
| 5 | +# Get the architecture from MACHTYPE: |
| 6 | +case "${MACHTYPE}" in |
| 7 | + aarch64-*) |
| 8 | + CS_ARCH="aarch64" |
| 9 | + ;; |
| 10 | + x86_64-*) |
| 11 | + CS_ARCH="x86_64" |
| 12 | + ;; |
| 13 | +esac |
| 14 | + |
| 15 | +# Download code_server JLL and just run it with some specific options |
| 16 | +CODE_SERVER_DIR="/tmp/code_server" |
| 17 | +CS_VERSION="4.99.2" |
| 18 | +BUILD_NUMBER="0" |
| 19 | + |
| 20 | +mkdir -p "${CODE_SERVER_DIR}" |
| 21 | +if [[ ! -f "${CODE_SERVER_DIR}/bin/code-server" ]]; then |
| 22 | + echo "Downloading code-server..." |
| 23 | + curl -#L "https://github.com/JuliaBinaryWrappers/code_server_jll.jl/releases/download/code_server-v${CS_VERSION}%2B${BUILD_NUMBER}/code_server.v${CS_VERSION}.${CS_ARCH}-linux-gnu.tar.gz" | tar -C "${CODE_SERVER_DIR}" -zx |
| 24 | +fi |
| 25 | + |
| 26 | +TAILSCALE_DIR="${CODE_SERVER_DIR}/tailscale" |
| 27 | +mkdir -p "${TAILSCALE_DIR}" |
| 28 | +if [[ ! -f "${TAILSCALE_DIR}/tailscale" ]]; then |
| 29 | + echo "Downloading tailscale..." |
| 30 | + case "${MACHTYPE}" in |
| 31 | + aarch64-*) |
| 32 | + TS_ARCH="arm64" |
| 33 | + ;; |
| 34 | + x86_64-*) |
| 35 | + TS_ARCH="amd64" |
| 36 | + ;; |
| 37 | + esac |
| 38 | + TS_VERSION="1.82.5" |
| 39 | + curl -#L "https://pkgs.tailscale.com/stable/tailscale_${TS_VERSION}_${TS_ARCH}.tgz" | tar -C "${TAILSCALE_DIR}" -zx --strip-components=1 |
| 40 | + |
| 41 | +fi |
| 42 | + |
| 43 | +# Start tailscaled |
| 44 | +if [[ ! -f "${TAILSCALE_DIR}/tailscaled.pid" ]]; then |
| 45 | + echo "Launching tailscaled..." |
| 46 | + "${TAILSCALE_DIR}/tailscaled" \ |
| 47 | + --tun=userspace-networking \ |
| 48 | + --state=mem: \ |
| 49 | + >>"${TAILSCALE_DIR}/tailscaled.log" 2>>"${TAILSCALE_DIR}/tailscaled.log" & |
| 50 | +fi |
| 51 | + |
| 52 | +echo "Logging in to tailscale..." |
| 53 | +"${TAILSCALE_DIR}/tailscale" login \ |
| 54 | + --hostname=${bb_build_identifier} \ |
| 55 | + --login-server=https://bb2-headscale.cflo.at \ |
| 56 | + --auth-key=530a716ebd6dbefb279d86453482d66a2928abefadc4e79b |
| 57 | + |
| 58 | +echo "Launching code-server..." |
| 59 | +echo "To connect, use one of:" |
| 60 | +echo " http://localhost:8080" |
| 61 | +echo " https://bb2.cflo.at/${bb_build_identifier}/" |
| 62 | + |
| 63 | +"${CODE_SERVER_DIR}/bin/code-server" \ |
| 64 | + --bind-addr=0.0.0.0:8080 \ |
| 65 | + --auth=none \ |
| 66 | + --disable-telemetry \ |
| 67 | + --disable-update-check \ |
| 68 | + --disable-workspace-trust \ |
| 69 | + --app-name "BB2 Debug UI" \ |
| 70 | + --welcome-text "Welcome to the BinaryBuilder2 debug interface" \ |
| 71 | + /workspace/srcdir >>"${CODE_SERVER_DIR}/code_server.log" 2>>"${CODE_SERVER_DIR}/code_server.log" |
| 72 | + |
| 73 | +echo "code-server exited, dumping logs:" |
| 74 | +echo |
| 75 | +for LOG_FILE in "${CODE_SERVER_DIR}/code_server.log" "${TAILSCALE_DIR}/tailscaled.log"; do |
| 76 | + echo ">>>>>>> $(basename "${LOG_FILE}") <<<<<<<" |
| 77 | + cat ${LOG_FILE} |
| 78 | + echo; echo; echo |
| 79 | +done |
0 commit comments