nose-pluto/scripts/generate-hosts.ts
Chris Wanstrath f62370c5f9 maybe
2025-09-16 21:44:05 -07:00

22 lines
618 B
TypeScript

import { $ } from "bun"
import { apps } from "../src/webapp"
const { stdout: ipRaw } = await $`hostname -I | awk '{print $1}'`.quiet()
const { stdout: hostRaw } = await $`hostname`.quiet()
const ip = ipRaw.toString().trim()
const host = hostRaw.toString().trim()
// 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(() => { })