2026-03-17 02:55:52 +00:00
|
|
|
// CLI command: serve
|
|
|
|
|
// Start the bastion server (HTTP + dnsmasq).
|
|
|
|
|
|
|
|
|
|
import type { Command } from "commander";
|
|
|
|
|
import { startBastion } from "../../server/main.js";
|
|
|
|
|
|
|
|
|
|
export function registerServeCommand(program: Command): void {
|
|
|
|
|
program
|
|
|
|
|
.command("serve")
|
|
|
|
|
.description("Start the bastion server (HTTP + dnsmasq PXE)")
|
|
|
|
|
.option("--port <port>", "HTTP port", "8080")
|
|
|
|
|
.option("--dir <dir>", "Bastion data directory", "/tmp/lab-bastion")
|
|
|
|
|
.option("--domain <domain>", "Internal domain for hostnames", "ad.itaz.eu")
|
|
|
|
|
.option("--dhcp-mode <mode>", "DHCP mode: proxy or full", "proxy")
|
|
|
|
|
.option("--fedora <version>", "Fedora version", "43")
|
|
|
|
|
.option("--arch <arch>", "Architecture", "x86_64")
|
|
|
|
|
.option("--timezone <tz>", "Timezone", "Europe/London")
|
|
|
|
|
.option("--locale <locale>", "Locale", "en_GB.UTF-8")
|
2026-03-17 03:11:29 +00:00
|
|
|
.option("--skip-dnsmasq", "Skip starting dnsmasq (for testing)")
|
|
|
|
|
.option("--skip-artifacts", "Skip downloading boot artifacts (for testing)")
|
2026-03-17 02:55:52 +00:00
|
|
|
.action(async (opts: {
|
|
|
|
|
port: string;
|
|
|
|
|
dir: string;
|
|
|
|
|
domain: string;
|
|
|
|
|
dhcpMode: string;
|
|
|
|
|
fedora: string;
|
|
|
|
|
arch: string;
|
|
|
|
|
timezone: string;
|
|
|
|
|
locale: string;
|
2026-03-17 03:11:29 +00:00
|
|
|
skipDnsmasq?: boolean;
|
|
|
|
|
skipArtifacts?: boolean;
|
2026-03-17 02:55:52 +00:00
|
|
|
}) => {
|
|
|
|
|
await startBastion({
|
|
|
|
|
httpPort: parseInt(opts.port, 10),
|
|
|
|
|
bastionDir: opts.dir,
|
|
|
|
|
domain: opts.domain,
|
|
|
|
|
dhcpMode: opts.dhcpMode as "proxy" | "full",
|
|
|
|
|
fedoraVersion: opts.fedora,
|
|
|
|
|
arch: opts.arch,
|
|
|
|
|
timezone: opts.timezone,
|
|
|
|
|
locale: opts.locale,
|
2026-03-17 03:11:29 +00:00
|
|
|
skipDnsmasq: opts.skipDnsmasq,
|
|
|
|
|
skipArtifacts: opts.skipArtifacts,
|
2026-03-17 02:55:52 +00:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|