fix: use either HEADSCALE_URL or config.server_url
This commit is contained in:
parent
a47fb61549
commit
78140927ad
3 changed files with 29 additions and 8 deletions
|
|
@ -161,6 +161,7 @@ type Context = {
|
|||
hasConfigWrite: boolean;
|
||||
hasAcl: boolean;
|
||||
hasAclWrite: boolean;
|
||||
headscaleUrl: string;
|
||||
}
|
||||
|
||||
export let context: Context
|
||||
|
|
@ -172,13 +173,29 @@ export async function getContext() {
|
|||
hasConfig: await hasConfig(),
|
||||
hasConfigWrite: await hasConfigW(),
|
||||
hasAcl: await hasAcl(),
|
||||
hasAclWrite: await hasAclW()
|
||||
hasAclWrite: await hasAclW(),
|
||||
headscaleUrl: await getHeadscaleUrl()
|
||||
}
|
||||
}
|
||||
|
||||
return context
|
||||
}
|
||||
|
||||
async function getHeadscaleUrl() {
|
||||
if (process.env.HEADSCALE_URL) {
|
||||
return process.env.HEADSCALE_URL
|
||||
}
|
||||
|
||||
try {
|
||||
const config = await getConfig()
|
||||
if (config.server_url) {
|
||||
return config.server_url
|
||||
}
|
||||
} catch {}
|
||||
|
||||
return ''
|
||||
}
|
||||
|
||||
async function checkSock() {
|
||||
try {
|
||||
await access('/var/run/docker.sock', constants.R_OK)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue