try it
This commit is contained in:
parent
ba344610ab
commit
74a101db93
|
|
@ -11,8 +11,7 @@
|
||||||
"remote:install": "./scripts/remote-install.sh",
|
"remote:install": "./scripts/remote-install.sh",
|
||||||
"remote:start": "./scripts/remote-start.sh",
|
"remote:start": "./scripts/remote-start.sh",
|
||||||
"remote:stop": "./scripts/remote-stop.sh",
|
"remote:stop": "./scripts/remote-stop.sh",
|
||||||
"remote:restart": "./scripts/remote-restart.sh",
|
"remote:restart": "./scripts/remote-restart.sh"
|
||||||
"generate-hosts": "./scripts/generate-hosts.sh"
|
|
||||||
},
|
},
|
||||||
"alias": {
|
"alias": {
|
||||||
"@utils": "./src/utils.tsx",
|
"@utils": "./src/utils.tsx",
|
||||||
|
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
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 ${app}.${host}.local -R ${ip}`).join("\n"))
|
|
||||||
|
|
||||||
const procs = apps().map(app =>
|
|
||||||
Bun.spawn(["avahi-publish", "-a", `${app}.${host}.local`, "-R", ip])
|
|
||||||
)
|
|
||||||
|
|
||||||
for (const p of procs)
|
|
||||||
p.exited.then(code =>
|
|
||||||
console.log(`avahi-publish (${p.pid}) exited with code ${code}`)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
await new Promise(() => { })
|
|
||||||
|
|
@ -5,7 +5,7 @@ import color from "kleur"
|
||||||
|
|
||||||
import { NOSE_ICON, NOSE_DIR, NOSE_BIN, NOSE_WWW } from "./config"
|
import { NOSE_ICON, NOSE_DIR, NOSE_BIN, NOSE_WWW } from "./config"
|
||||||
import { transpile, isFile, tilde } from "./utils"
|
import { transpile, isFile, tilde } from "./utils"
|
||||||
import { apps, serveApp } from "./webapp"
|
import { apps, serveApp, publishDNS } from "./webapp"
|
||||||
|
|
||||||
import { Layout } from "./components/layout"
|
import { Layout } from "./components/layout"
|
||||||
import { Terminal } from "./components/terminal"
|
import { Terminal } from "./components/terminal"
|
||||||
|
|
@ -97,6 +97,8 @@ if (process.env.BUN_HOT) {
|
||||||
process.exit()
|
process.exit()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
publishDNS()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -68,4 +68,24 @@ export function toResponse(source: string | Child | Response): Response {
|
||||||
"Content-Type": "text/html; charset=utf-8"
|
"Content-Type": "text/html; charset=utf-8"
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function publishDNS() {
|
||||||
|
const { stdout: ipRaw } = await Bun.$`hostname -I | awk '{print $1}'`.quiet()
|
||||||
|
const { stdout: hostRaw } = await Bun.$`hostname`.quiet()
|
||||||
|
|
||||||
|
const ip = ipRaw.toString().trim()
|
||||||
|
const host = hostRaw.toString().trim()
|
||||||
|
|
||||||
|
const procs = apps().map(app =>
|
||||||
|
Bun.spawn(["avahi-publish", "-a", `${app}.${host}.local`, "-R", ip])
|
||||||
|
)
|
||||||
|
|
||||||
|
const signals = ["SIGINT", "SIGTERM"]
|
||||||
|
signals.forEach(sig =>
|
||||||
|
process.on(sig, () => {
|
||||||
|
procs.forEach(p => p.kill("SIGTERM"))
|
||||||
|
process.exit(0)
|
||||||
|
})
|
||||||
|
)
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user