Use dynamic hostname instead of toes.local
This commit is contained in:
parent
51e42dc538
commit
0499060676
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
# It isn't enough to modify this yet.
|
||||
# You also need to manually update the toes.service file.
|
||||
HOST="${HOST:-toes@toes.local}"
|
||||
URL="${URL:-http://toes.local}"
|
||||
HOST="${HOST:-toes@$(hostname).local}"
|
||||
URL="${URL:-http://$(hostname).local}"
|
||||
DEST="${DEST:-~/toes}"
|
||||
DATA_DIR="${DATA_DIR:-~/data}"
|
||||
APPS_DIR="${APPS_DIR:-~/apps}"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import type { Manifest } from '@types'
|
||||
import { hostname } from 'os'
|
||||
|
||||
const DEFAULT_HOST = process.env.DEV ? 'http://localhost:3000' : 'http://toes.local'
|
||||
const DEFAULT_HOST = process.env.DEV ? 'http://localhost:3000' : `http://${hostname()}.local`
|
||||
|
||||
const normalizeUrl = (url: string) =>
|
||||
url.startsWith('http://') || url.startsWith('https://') ? url : `http://${url}`
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ async function buildBinary(name: string): Promise<boolean> {
|
|||
return promise
|
||||
}
|
||||
|
||||
// Install script: curl -fsSL http://toes.local/install | bash
|
||||
// Install script: curl -fsSL http://<hostname>.local/install | bash
|
||||
app.get('/install', c => {
|
||||
if (!TOES_URL) return c.text('TOES_URL is not configured', 500)
|
||||
const script = INSTALL_SCRIPT.replace('__TOES_URL__', TOES_URL)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import type { Subprocess } from 'bun'
|
||||
import { toSubdomain } from '@urls'
|
||||
import { networkInterfaces } from 'os'
|
||||
import { hostname, networkInterfaces } from 'os'
|
||||
import { hostLog } from './tui'
|
||||
|
||||
const _publishers = new Map<string, Subprocess>()
|
||||
|
|
@ -24,7 +24,7 @@ export function cleanupStalePublishers() {
|
|||
if (!isEnabled) return
|
||||
|
||||
try {
|
||||
const result = Bun.spawnSync(['pkill', '-f', 'avahi-publish.*toes\\.local'])
|
||||
const result = Bun.spawnSync(['pkill', '-f', `avahi-publish.*${hostname()}\\.local`])
|
||||
if (result.exitCode === 0) {
|
||||
hostLog('mDNS: cleaned up stale avahi-publish processes')
|
||||
}
|
||||
|
|
@ -41,22 +41,22 @@ export function publishApp(name: string) {
|
|||
return
|
||||
}
|
||||
|
||||
const hostname = `${toSubdomain(name)}.toes.local`
|
||||
const host = `${toSubdomain(name)}.${hostname()}.local`
|
||||
|
||||
try {
|
||||
const proc = Bun.spawn(['avahi-publish', '-a', hostname, '-R', ip], {
|
||||
const proc = Bun.spawn(['avahi-publish', '-a', host, '-R', ip], {
|
||||
stdout: 'ignore',
|
||||
stderr: 'ignore',
|
||||
})
|
||||
|
||||
_publishers.set(name, proc)
|
||||
hostLog(`mDNS: published ${hostname} -> ${ip}`)
|
||||
hostLog(`mDNS: published ${host} -> ${ip}`)
|
||||
|
||||
proc.exited.then(() => {
|
||||
_publishers.delete(name)
|
||||
})
|
||||
} catch {
|
||||
hostLog(`mDNS: failed to publish ${hostname}`)
|
||||
hostLog(`mDNS: failed to publish ${host}`)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -68,7 +68,7 @@ export function unpublishApp(name: string) {
|
|||
|
||||
proc.kill()
|
||||
_publishers.delete(name)
|
||||
hostLog(`mDNS: unpublished ${toSubdomain(name)}.toes.local`)
|
||||
hostLog(`mDNS: unpublished ${toSubdomain(name)}.${hostname()}.local`)
|
||||
}
|
||||
|
||||
export function unpublishAll() {
|
||||
|
|
@ -76,7 +76,7 @@ export function unpublishAll() {
|
|||
|
||||
for (const [name, proc] of _publishers) {
|
||||
proc.kill()
|
||||
hostLog(`mDNS: unpublished ${toSubdomain(name)}.toes.local`)
|
||||
hostLog(`mDNS: unpublished ${toSubdomain(name)}.${hostname()}.local`)
|
||||
}
|
||||
_publishers.clear()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user