From f62370c5f912ebc18ae25598d223fbe3d88dfc76 Mon Sep 17 00:00:00 2001 From: Chris Wanstrath <2+defunkt@users.noreply.github.com> Date: Tue, 16 Sep 2025 21:44:05 -0700 Subject: [PATCH] maybe --- scripts/generate-hosts.sh | 3 --- scripts/generate-hosts.ts | 21 +++++++++++++++++---- 2 files changed, 17 insertions(+), 7 deletions(-) delete mode 100755 scripts/generate-hosts.sh diff --git a/scripts/generate-hosts.sh b/scripts/generate-hosts.sh deleted file mode 100755 index 1b8003d..0000000 --- a/scripts/generate-hosts.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash -bun ./scripts/generate-hosts.ts > /etc/avahi/hosts -sudo systemctl restart avahi-daemon \ No newline at end of file diff --git a/scripts/generate-hosts.ts b/scripts/generate-hosts.ts index b265061..351fa50 100644 --- a/scripts/generate-hosts.ts +++ b/scripts/generate-hosts.ts @@ -1,9 +1,22 @@ import { $ } from "bun" import { apps } from "../src/webapp" -const { stdout: ip } = await $`hostname -I | awk '{print $1}'`.quiet() -const { stdout: host } = await $`hostname`.quiet() +const { stdout: ipRaw } = await $`hostname -I | awk '{print $1}'`.quiet() +const { stdout: hostRaw } = await $`hostname`.quiet() -const hosts = apps().map(app => `${ip.toString().trim()} ${app}.${host.toString().trim()}.local`) +const ip = ipRaw.toString().trim() +const host = hostRaw.toString().trim() -console.log(hosts.join("\n")) \ No newline at end of file +// console.log(apps().map(app => `avahi-publish -a -R ${app}.${host} ${ip} &`).join("\n")) + +const procs = apps().map(app => + Bun.spawn(["avahi-publish", "-a", "-R", `${app}.${host}`, ip]) +) + +for (const p of procs) + p.exited.then(code => + console.log(`avahi-publish (${p.pid}) exited with code ${code}`) + ) + + +await new Promise(() => { }) \ No newline at end of file