|
| 1 | +#! /usr/bin/env -S deno run --allow-run --allow-net --allow-read --allow-write --allow-env |
| 2 | + |
| 3 | +/* |
| 4 | + * This Source Code Form is subject to the terms of the Mozilla Public |
| 5 | + * License, v. 2.0. If a copy of the MPL was not distributed with this |
| 6 | + * file, you can obtain one at https://mozilla.org/MPL/2.0/. |
| 7 | + * |
| 8 | + * Copyright Oxide Computer Company |
| 9 | + */ |
| 10 | +import $ from 'jsr:@david/dax@0.41.0' |
| 11 | +import { parseArgs } from 'jsr:@std/cli@0.224.7' |
| 12 | + |
| 13 | +// This script will not work unless you have the following helpful bits in your SSH config: |
| 14 | +// |
| 15 | +// Host gc* |
| 16 | +// StrictHostKeyChecking no |
| 17 | +// UserKnownHostsFile /dev/null |
| 18 | +// User root |
| 19 | +// ProxyCommand ssh jeeves.eng.oxide.computer pilot tp nc any $(echo "%h" | sed s/gc//) %p |
| 20 | +// ServerAliveInterval 15 |
| 21 | +// ForwardAgent yes |
| 22 | +// |
| 23 | +// host jeeves |
| 24 | +// hostname %h.eng.oxide.computer |
| 25 | +// user <your actual username> |
| 26 | +// ForwardAgent yes |
| 27 | + |
| 28 | +const USAGE = ` |
| 29 | +Usage: |
| 30 | +
|
| 31 | + tools/deno/dogfood-deploy.ts <console commit hash> |
| 32 | +`.trim() |
| 33 | + |
| 34 | +const args = parseArgs(Deno.args) |
| 35 | +const consoleCommit = args._[0] |
| 36 | + |
| 37 | +if (!consoleCommit) { |
| 38 | + console.error('Error: Console commit hash is required\n') |
| 39 | + console.log(USAGE) |
| 40 | + Deno.exit(1) |
| 41 | +} |
| 42 | + |
| 43 | +console.log('Finding nexus zones...') |
| 44 | +const zones: string = await $`./tools/dogfood/find-zone.sh nexus`.text() |
| 45 | +const gimletNums = zones |
| 46 | + .split('\n') |
| 47 | + .filter((line) => line.includes('nexus')) |
| 48 | + .map((line) => line.trim().split(' ')[0]) |
| 49 | + |
| 50 | +console.log(`Found: ${JSON.stringify(gimletNums)}\n`) |
| 51 | + |
| 52 | +const TARBALL_URL = `https://dl.oxide.computer/releases/console/${consoleCommit}.tar.gz` |
| 53 | +const TARBALL_FILE = '/tmp/console.tar.gz' |
| 54 | + |
| 55 | +console.log(`Downloading tarball to ${TARBALL_FILE}`) |
| 56 | +await $`curl --show-error --fail --location --output ${TARBALL_FILE} ${TARBALL_URL}` |
| 57 | +console.log(`Done downloading.\n`) |
| 58 | + |
| 59 | +const go = await $.confirm(`Deploy console to gimlets ${JSON.stringify(gimletNums)}?`) |
| 60 | +if (!go) { |
| 61 | + console.log('Deploy aborted') |
| 62 | + Deno.exit() |
| 63 | +} |
| 64 | + |
| 65 | +async function deploy(num: string) { |
| 66 | + console.log(`Deploying to gimlet ${num}...`) |
| 67 | + await $`./tools/dogfood/scp-assets.sh gc${num} ${TARBALL_FILE}` |
| 68 | + console.log(`Done with gimlet ${num}...`) |
| 69 | +} |
| 70 | + |
| 71 | +await Promise.all(gimletNums.map(deploy)) |
0 commit comments