This commit is contained in:
Chris Wanstrath 2025-09-16 21:44:05 -07:00
parent 594fb6816a
commit f62370c5f9
2 changed files with 17 additions and 7 deletions

View File

@ -1,3 +0,0 @@
#!/usr/bin/env bash
bun ./scripts/generate-hosts.ts > /etc/avahi/hosts
sudo systemctl restart avahi-daemon

View File

@ -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"))
// 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(() => { })