home-hosted 0.10.1 → 0.10.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/cli.js +218 -49
- package/dist/cli.js.map +1 -1
- package/docs/SERVERS.md +23 -33
- package/package.json +1 -1
- package/uis/stock/dist/assets/de-CiSKBON6.js +1 -0
- package/uis/stock/dist/assets/es-BgNQbboq.js +1 -0
- package/uis/stock/dist/assets/fr-WzBF8AXI.js +1 -0
- package/uis/stock/dist/assets/{index-Dm3f5Ssr.js → index-CXDl25BP.js} +12 -12
- package/uis/stock/dist/assets/ja-DMQqF4ip.js +1 -0
- package/uis/stock/dist/assets/ko-DgfSg9v_.js +1 -0
- package/uis/stock/dist/assets/ru-DjIByX61.js +1 -0
- package/uis/stock/dist/assets/vi-DOB8nYFC.js +1 -0
- package/uis/stock/dist/assets/zh-CN-DZ3WlUgy.js +1 -0
- package/uis/stock/dist/index.html +1 -1
- package/uis/stock/dist/ui.json +3 -3
- package/uis/stock/dist/assets/de-Dy66GhJ0.js +0 -1
- package/uis/stock/dist/assets/es-DV-Sq6ZE.js +0 -1
- package/uis/stock/dist/assets/fr-DgypPCaQ.js +0 -1
- package/uis/stock/dist/assets/ja-BckgJ7ql.js +0 -1
- package/uis/stock/dist/assets/ko-B4wj7dOk.js +0 -1
- package/uis/stock/dist/assets/ru-jU0fytv4.js +0 -1
- package/uis/stock/dist/assets/vi-DG3AWtuR.js +0 -1
- package/uis/stock/dist/assets/zh-CN-Bk5kP2q-.js +0 -1
package/README.md
CHANGED
|
@@ -320,13 +320,13 @@ can be told what to be: *"Help me build a UI for home-hosted: nostalgic game the
|
|
|
320
320
|
| 🔗 **Ordered startup** | `dependsOn` waits for a dependency to be *healthy* — not merely spawned. `stop-all`/`down` stop dependents before their dependencies; stopping one server names the dependents it leaves running. [SERVERS.md](./docs/SERVERS.md#field-reference) |
|
|
321
321
|
| 📜 **Logs** | Live per-server stream, buffer plus rotated files on disk, search, filter to one stream, download, one click to clear. `Keep rotated files` in **Workspace Settings** bounds the directory, and the search reads every rotation it keeps — lowering it deletes the extras. |
|
|
322
322
|
| 📈 **Resources** | CPU and RSS per process tree — the summed containers for a compose entry — with an optional memory ceiling that restarts the entry. Stopping a compose entry stops its containers even when the wrapper is gone, and says so if one survives. [SERVERS.md](./docs/SERVERS.md#docker-and-compose) |
|
|
323
|
-
| 🌡️ **Host vitals** | CPU usage, memory, swap, disk and CPU temperature, plus the load average as a per-cpu count, with thresholds that notify once and again on recovery. Where the OS exposes no sensor — a WSL2 guest above all — the tile says `n/a`; [
|
|
323
|
+
| 🌡️ **Host vitals** | CPU usage, memory, swap, disk and CPU temperature, plus the load average as a per-cpu count, with thresholds that notify once and again on recovery. Where the OS exposes no sensor — a WSL2 guest above all — the tile says `n/a`; [`setup-temp --wsl`](./docs/SERVERS.md#cpu-temperature-where-the-os-exposes-none) bridges to the Windows host. |
|
|
324
324
|
| 🤖 **Token API** | Scripts and agents drive it with `Authorization: Bearer` — no browser, no session. [↑](#-agents-scripts-and-tools) |
|
|
325
325
|
| 🔔 **Notifications** | Telegram and webhooks (ntfy, Discord, Slack, anything) on crash, unhealthy, recovery, host thresholds and DNS changes. Toggles and throttle set once; each destination inherits or overrides. [Setup](./docs/NOTIFICATIONS.md). |
|
|
326
326
|
| 🌐 **Dynamic DNS** | Keep hostnames pointed at your public IP — Cloudflare, Namecheap, Spaceship, Porkbun, GoDaddy, Gandi and more. [DDNS.md](./docs/DDNS.md) |
|
|
327
327
|
| 🔀 **Reverse proxy** | One Caddy engine in front of everything, with automatic HTTPS: `git.example.com` → a Gitea entry, `panel.example.com` → the panel itself. Installed and supervised by it. [Details](./docs/REVERSE_PROXY.md) |
|
|
328
328
|
| 💾 **Backups** | One `.zip` of the panel and the workspaces you pick — plain or AES-256, picked per item, from the panel or the CLI. [Details](#-backups). |
|
|
329
|
-
| 🌍 **
|
|
329
|
+
| 🌍 **Translated UI** | English, Vietnamese, Chinese, Japanese, Spanish, Korean, Russian, French and German — picked on the login page or in **Global settings → Language**, kept per browser. Action toasts included. The NOC console ships English-only on purpose; its density is the point. |
|
|
330
330
|
| 🎨 **BYOU — Bring Your Own UI** | Upload a static build, `ui-update` to follow its releases, `ui-revert` to go back. [UI_CREATION.md](./docs/UI_CREATION.md) |
|
|
331
331
|
| 🔐 **Security** | Cookie sessions, API tokens, scrypt hashes, per-IP lockout, optional TLS, and a refusal to expose itself without a password. |
|
|
332
332
|
| 🧩 **Bring any program** | A server is a `command`, its args and a working directory — plus optional `dataEnvs`, `dependsOn` and `dump`/`load` hooks. Presets fill the form; nothing requires one. [Fields](./docs/SERVERS.md) |
|
package/dist/cli.js
CHANGED
|
@@ -13,7 +13,7 @@ import { LogLevels, createConsola } from "consola";
|
|
|
13
13
|
import { isDevelopment } from "std-env";
|
|
14
14
|
import { DetailedError } from "@namesmt/utils";
|
|
15
15
|
import { type } from "arktype";
|
|
16
|
-
import crypto, { X509Certificate, createPrivateKey, createPublicKey, randomBytes } from "node:crypto";
|
|
16
|
+
import crypto, { X509Certificate, createHash, createPrivateKey, createPublicKey, randomBytes } from "node:crypto";
|
|
17
17
|
import { Readable, Writable } from "node:stream";
|
|
18
18
|
import { bodyLimit } from "hono/body-limit";
|
|
19
19
|
import { streamSSE } from "hono/streaming";
|
|
@@ -1880,7 +1880,14 @@ maxRssBytes: "number.integer >= 0 = 0" }).onUndeclaredKey("reject");
|
|
|
1880
1880
|
/** The last probe's reading, so the page can say "this works" without running it again. */
|
|
1881
1881
|
"lastReadingCelsius?": "number | null",
|
|
1882
1882
|
/** Why the last probe failed, if it did — a missing library and no sensor read differently. */
|
|
1883
|
-
"lastError?": "string | null"
|
|
1883
|
+
"lastError?": "string | null",
|
|
1884
|
+
/**
|
|
1885
|
+
* The library is missing and installing it needs consent.
|
|
1886
|
+
*
|
|
1887
|
+
* The panel will not download a third-party binary on a click that did not mention one, so the
|
|
1888
|
+
* first press answers `needsDownload` and the page asks. Absent on an older panel.
|
|
1889
|
+
*/
|
|
1890
|
+
"needsDownload?": "boolean"
|
|
1884
1891
|
});
|
|
1885
1892
|
backupFileSchema = type({
|
|
1886
1893
|
name: "string",
|
|
@@ -12984,14 +12991,52 @@ var init_$_routes = __esmMin((() => {
|
|
|
12984
12991
|
//#endregion
|
|
12985
12992
|
//#region src/providers/wsl-temperature.ts
|
|
12986
12993
|
var wsl_temperature_exports = /* @__PURE__ */ __exportAll({
|
|
12994
|
+
LHM_RELEASE: () => LHM_RELEASE,
|
|
12995
|
+
LHM_SUBDIR: () => LHM_SUBDIR,
|
|
12996
|
+
installLibreHardwareMonitor: () => installLibreHardwareMonitor,
|
|
12987
12997
|
isWsl: () => isWsl,
|
|
12998
|
+
lhmDirectory: () => lhmDirectory,
|
|
12999
|
+
lhmDirectoryWindows: () => lhmDirectoryWindows,
|
|
13000
|
+
lhmInstalled: () => lhmInstalled,
|
|
12988
13001
|
probeWslTemperature: () => probeWslTemperature,
|
|
12989
13002
|
tempCommandFor: () => tempCommandFor,
|
|
13003
|
+
tempCommandForWindows: () => tempCommandForWindows,
|
|
13004
|
+
toGuestPath: () => toGuestPath,
|
|
12990
13005
|
windowsScriptPath: () => windowsScriptPath,
|
|
12991
13006
|
writeWslTemperatureScript: () => writeWslTemperatureScript,
|
|
12992
13007
|
wslScriptPath: () => wslScriptPath,
|
|
13008
|
+
wslScriptPathWindows: () => wslScriptPathWindows,
|
|
12993
13009
|
wslTemperatureStatus: () => wslTemperatureStatus
|
|
12994
13010
|
});
|
|
13011
|
+
/** The install directory in Windows terms, read from the environment (the system drive may not be `C:`). */
|
|
13012
|
+
function lhmDirectoryWindows() {
|
|
13013
|
+
try {
|
|
13014
|
+
const base = execFileSync("powershell.exe", [
|
|
13015
|
+
"-NoProfile",
|
|
13016
|
+
"-NonInteractive",
|
|
13017
|
+
"-Command",
|
|
13018
|
+
"$env:ProgramData"
|
|
13019
|
+
], {
|
|
13020
|
+
timeout: 1e4,
|
|
13021
|
+
windowsHide: true,
|
|
13022
|
+
encoding: "utf8"
|
|
13023
|
+
}).trim();
|
|
13024
|
+
return base.length === 0 ? null : path.win32.join(base, LHM_SUBDIR);
|
|
13025
|
+
} catch {
|
|
13026
|
+
return null;
|
|
13027
|
+
}
|
|
13028
|
+
}
|
|
13029
|
+
/** A Windows path as a path this process can read: `C:\x` -> `/mnt/c/x`. */
|
|
13030
|
+
function toGuestPath(windowsPath) {
|
|
13031
|
+
const match = /^([a-z]):\\(.*)$/i.exec(windowsPath);
|
|
13032
|
+
if (match === null) return null;
|
|
13033
|
+
return path.posix.join("/mnt", match[1].toLowerCase(), ...match[2].split("\\"));
|
|
13034
|
+
}
|
|
13035
|
+
/** The install directory as a guest path, or null when the Windows side cannot be reached. */
|
|
13036
|
+
function lhmDirectory() {
|
|
13037
|
+
const windows = lhmDirectoryWindows();
|
|
13038
|
+
return windows === null ? null : toGuestPath(windows);
|
|
13039
|
+
}
|
|
12995
13040
|
/**
|
|
12996
13041
|
* Whether this process is a WSL2 guest.
|
|
12997
13042
|
*
|
|
@@ -13006,40 +13051,38 @@ function isWsl() {
|
|
|
13006
13051
|
return false;
|
|
13007
13052
|
}
|
|
13008
13053
|
}
|
|
13009
|
-
/**
|
|
13010
|
-
* Where the helper script goes: **on the Windows side**, under `%LOCALAPPDATA%`-style storage.
|
|
13011
|
-
*
|
|
13012
|
-
* This is the part that is easy to get wrong. `powershell.exe` reads a *Windows* path, so a script
|
|
13013
|
-
* written into the guest's Linux home (`/tmp`, `~/.home-hosted`) is invisible to it — the command
|
|
13014
|
-
* appears to work only while some stale copy exists, then fails with a path error that names nothing
|
|
13015
|
-
* useful. `/mnt/c` is the 9p mount of `C:`, so writing there gives both sides the same file.
|
|
13016
|
-
*/
|
|
13054
|
+
/** A `/mnt/c/...` path as the `C:\...` path `powershell.exe` needs. Untranslatable paths pass through. */
|
|
13017
13055
|
function windowsScriptPath(scriptPath) {
|
|
13018
13056
|
const match = /^\/mnt\/([a-z])\/(.*)$/i.exec(scriptPath);
|
|
13019
13057
|
if (match === null) return scriptPath;
|
|
13020
13058
|
return `${match[1].toUpperCase()}:\\${match[2].replaceAll("/", "\\")}`;
|
|
13021
13059
|
}
|
|
13022
|
-
/**
|
|
13023
|
-
* The Linux path the helper is written to: `C:\Tools\home-hosted\cpu-temp.ps1` on Windows.
|
|
13024
|
-
*
|
|
13025
|
-
* `user` is the Windows-side account, taken from the mount when it can be read. Falls back to the
|
|
13026
|
-
* user's home on the Windows drive, which is where a person can find and delete the file.
|
|
13027
|
-
*/
|
|
13060
|
+
/** The helper script, written beside the library so every account resolves the same file. */
|
|
13028
13061
|
function wslScriptPath() {
|
|
13029
13062
|
if (!isWsl()) return null;
|
|
13030
|
-
|
|
13063
|
+
const base = lhmDirectoryWindows();
|
|
13064
|
+
const guest = base === null ? null : toGuestPath(path.win32.dirname(base));
|
|
13065
|
+
if (guest === null) return null;
|
|
13066
|
+
return path.join(guest, SCRIPT_NAME);
|
|
13067
|
+
}
|
|
13068
|
+
/** Where the helper is, in Windows terms — what the command line has to say. */
|
|
13069
|
+
function wslScriptPathWindows() {
|
|
13070
|
+
const base = lhmDirectoryWindows();
|
|
13071
|
+
return base === null ? null : path.win32.join(path.win32.dirname(base), SCRIPT_NAME);
|
|
13031
13072
|
}
|
|
13032
13073
|
/** The `powershell.exe` invocation that runs `scriptPath` and prints the temperature. */
|
|
13033
13074
|
function tempCommandFor(scriptPath) {
|
|
13034
13075
|
return `powershell.exe -NoProfile -ExecutionPolicy Bypass -File "${windowsScriptPath(scriptPath)}"`;
|
|
13035
13076
|
}
|
|
13077
|
+
/** The command for a path already expressed in Windows terms. */
|
|
13078
|
+
function tempCommandForWindows(windowsPath) {
|
|
13079
|
+
return `powershell.exe -NoProfile -ExecutionPolicy Bypass -File "${windowsPath}"`;
|
|
13080
|
+
}
|
|
13036
13081
|
/** The script's body. Kept tiny: it runs on every host sample. */
|
|
13037
|
-
function scriptBody(
|
|
13038
|
-
return `# CPU temperature for home-hosted
|
|
13039
|
-
|
|
13040
|
-
|
|
13041
|
-
$dir = '${lhmDir}'
|
|
13042
|
-
if (-not (Test-Path "$dir\\LibreHardwareMonitorLib.dll")) {
|
|
13082
|
+
function scriptBody() {
|
|
13083
|
+
return `# CPU temperature for home-hosted. Written by \`home-hosted setup-temp --wsl\`; safe to delete.
|
|
13084
|
+
$dir = Join-Path $env:ProgramData 'home-hosted\\LibreHardwareMonitor'
|
|
13085
|
+
if (-not (Test-Path (Join-Path $dir 'LibreHardwareMonitorLib.dll'))) {
|
|
13043
13086
|
[Console]::Error.WriteLine("LibreHardwareMonitor not found in $dir")
|
|
13044
13087
|
exit 1
|
|
13045
13088
|
}
|
|
@@ -13066,28 +13109,17 @@ if ($null -eq $out) { exit 2 }
|
|
|
13066
13109
|
$out
|
|
13067
13110
|
`;
|
|
13068
13111
|
}
|
|
13069
|
-
/**
|
|
13070
|
-
* Whether the setup is in place: the script exists, and the panel has been pointed at it.
|
|
13071
|
-
*
|
|
13072
|
-
* `configured` is what the panel *will do*; `ready` is whether it can work — the two are separate so
|
|
13073
|
-
* the UI can say "set up, but the library is missing" rather than only "not set up".
|
|
13074
|
-
*/
|
|
13112
|
+
/** `configured` (pointed at a command) and `libraryPresent` are separate, so the UI can say "set up, but the library is missing". */
|
|
13075
13113
|
function wslTemperatureStatus(scriptPath, tempCommand) {
|
|
13076
13114
|
const wsl = isWsl();
|
|
13077
13115
|
const scriptWritten = scriptPath !== null && fs.existsSync(scriptPath);
|
|
13078
13116
|
const configured = tempCommand.trim().length > 0;
|
|
13079
|
-
let libraryPresent = false;
|
|
13080
|
-
try {
|
|
13081
|
-
libraryPresent = fs.existsSync(path.join("/mnt", "c", "Tools", "LibreHardwareMonitor", "LibreHardwareMonitorLib.dll"));
|
|
13082
|
-
} catch {
|
|
13083
|
-
libraryPresent = false;
|
|
13084
|
-
}
|
|
13085
13117
|
return {
|
|
13086
13118
|
wsl,
|
|
13087
13119
|
supported: wsl,
|
|
13088
13120
|
configured,
|
|
13089
13121
|
scriptWritten,
|
|
13090
|
-
libraryPresent,
|
|
13122
|
+
libraryPresent: lhmInstalled(),
|
|
13091
13123
|
scriptPath: wsl ? scriptPath : null,
|
|
13092
13124
|
tempCommand: configured ? tempCommand : null
|
|
13093
13125
|
};
|
|
@@ -13095,15 +13127,94 @@ function wslTemperatureStatus(scriptPath, tempCommand) {
|
|
|
13095
13127
|
/** Write the helper script. Idempotent: re-running overwrites it with the current version. */
|
|
13096
13128
|
function writeWslTemperatureScript(scriptPath) {
|
|
13097
13129
|
fs.mkdirSync(path.dirname(scriptPath), { recursive: true });
|
|
13098
|
-
fs.writeFileSync(scriptPath, scriptBody(
|
|
13130
|
+
fs.writeFileSync(scriptPath, scriptBody(), { mode: 384 });
|
|
13099
13131
|
}
|
|
13100
|
-
/**
|
|
13101
|
-
|
|
13102
|
-
|
|
13103
|
-
|
|
13104
|
-
|
|
13105
|
-
|
|
13106
|
-
|
|
13132
|
+
/** Whether the DLL the helper loads is installed where the helper expects it. */
|
|
13133
|
+
function lhmInstalled() {
|
|
13134
|
+
const dir = lhmDirectory();
|
|
13135
|
+
if (dir === null) return false;
|
|
13136
|
+
try {
|
|
13137
|
+
return fs.existsSync(path.join(dir, "LibreHardwareMonitorLib.dll"));
|
|
13138
|
+
} catch {
|
|
13139
|
+
return false;
|
|
13140
|
+
}
|
|
13141
|
+
}
|
|
13142
|
+
/** Download, verify and unpack LibreHardwareMonitor. A failed attempt leaves nothing installed. */
|
|
13143
|
+
async function installLibreHardwareMonitor(options = {}) {
|
|
13144
|
+
const report = options.onProgress ?? (() => {});
|
|
13145
|
+
const targetWindows = lhmDirectoryWindows();
|
|
13146
|
+
const target = lhmDirectory();
|
|
13147
|
+
if (targetWindows === null || target === null) return {
|
|
13148
|
+
dir: null,
|
|
13149
|
+
error: "the Windows ProgramData directory could not be read, so there is nowhere to install to"
|
|
13150
|
+
};
|
|
13151
|
+
let staging = null;
|
|
13152
|
+
try {
|
|
13153
|
+
report(`downloading ${LHM_RELEASE.asset} (${LHM_RELEASE.version})…`);
|
|
13154
|
+
const response = await fetch(LHM_RELEASE.url, {
|
|
13155
|
+
redirect: "follow",
|
|
13156
|
+
signal: AbortSignal.timeout(12e4)
|
|
13157
|
+
});
|
|
13158
|
+
if (!response.ok) return {
|
|
13159
|
+
dir: null,
|
|
13160
|
+
error: `the download answered ${response.status} for ${LHM_RELEASE.url}`
|
|
13161
|
+
};
|
|
13162
|
+
const bytes = Buffer$1.from(await response.arrayBuffer());
|
|
13163
|
+
const digest = createHash("sha256").update(bytes).digest("hex");
|
|
13164
|
+
if (digest !== LHM_RELEASE.sha256) return {
|
|
13165
|
+
dir: null,
|
|
13166
|
+
error: `the download did not match its published sha256 (got ${digest.slice(0, 16)}…, expected ${LHM_RELEASE.sha256.slice(0, 16)}…) — nothing was installed`
|
|
13167
|
+
};
|
|
13168
|
+
const stagingRoot = path.join(path.dirname(target), ".staging");
|
|
13169
|
+
await fs.promises.mkdir(stagingRoot, { recursive: true });
|
|
13170
|
+
staging = await fs.promises.mkdtemp(path.join(stagingRoot, "run-"));
|
|
13171
|
+
const archive = path.join(staging, LHM_RELEASE.asset);
|
|
13172
|
+
await fs.promises.writeFile(archive, bytes);
|
|
13173
|
+
report(`unpacking into ${targetWindows}…`);
|
|
13174
|
+
await fs.promises.rm(target, {
|
|
13175
|
+
recursive: true,
|
|
13176
|
+
force: true
|
|
13177
|
+
});
|
|
13178
|
+
await fs.promises.mkdir(target, { recursive: true });
|
|
13179
|
+
await execFileAsync$2("powershell.exe", [
|
|
13180
|
+
"-NoProfile",
|
|
13181
|
+
"-NonInteractive",
|
|
13182
|
+
"-Command",
|
|
13183
|
+
`Expand-Archive -LiteralPath '${windowsScriptPath(archive)}' -DestinationPath '${targetWindows}' -Force`
|
|
13184
|
+
], {
|
|
13185
|
+
timeout: 12e4,
|
|
13186
|
+
windowsHide: true
|
|
13187
|
+
});
|
|
13188
|
+
if (!lhmInstalled()) {
|
|
13189
|
+
await fs.promises.rm(target, {
|
|
13190
|
+
recursive: true,
|
|
13191
|
+
force: true
|
|
13192
|
+
}).catch(() => {});
|
|
13193
|
+
return {
|
|
13194
|
+
dir: null,
|
|
13195
|
+
error: `the archive unpacked but LibreHardwareMonitorLib.dll is not in ${targetWindows}`
|
|
13196
|
+
};
|
|
13197
|
+
}
|
|
13198
|
+
return {
|
|
13199
|
+
dir: targetWindows,
|
|
13200
|
+
error: null
|
|
13201
|
+
};
|
|
13202
|
+
} catch (error) {
|
|
13203
|
+
return {
|
|
13204
|
+
dir: null,
|
|
13205
|
+
error: error instanceof Error ? error.message : String(error)
|
|
13206
|
+
};
|
|
13207
|
+
} finally {
|
|
13208
|
+
if (staging !== null) {
|
|
13209
|
+
await fs.promises.rm(staging, {
|
|
13210
|
+
recursive: true,
|
|
13211
|
+
force: true
|
|
13212
|
+
}).catch(() => {});
|
|
13213
|
+
await fs.promises.rmdir(path.dirname(staging)).catch(() => {});
|
|
13214
|
+
}
|
|
13215
|
+
}
|
|
13216
|
+
}
|
|
13217
|
+
/** Run the helper once, so a setup that cannot work is reported rather than saved. */
|
|
13107
13218
|
async function probeWslTemperature(tempCommand, timeoutMs) {
|
|
13108
13219
|
try {
|
|
13109
13220
|
const { stdout, stderr } = await execFileAsync$2(tempCommand, {
|
|
@@ -13115,7 +13226,7 @@ async function probeWslTemperature(tempCommand, timeoutMs) {
|
|
|
13115
13226
|
const match = /-?\d+(?:\.\d+)?/.exec(stdout);
|
|
13116
13227
|
if (match === null) return {
|
|
13117
13228
|
celsius: null,
|
|
13118
|
-
error: stderr.trim().length > 0 ? stderr.trim() : "the script printed no number — is LibreHardwareMonitor installed
|
|
13229
|
+
error: stderr.trim().length > 0 ? stderr.trim() : "the script printed no number — is LibreHardwareMonitor installed?"
|
|
13119
13230
|
};
|
|
13120
13231
|
const celsius = Number.parseFloat(match[0]);
|
|
13121
13232
|
if (!Number.isFinite(celsius) || celsius <= 0 || celsius >= 150) return {
|
|
@@ -13135,12 +13246,19 @@ async function probeWslTemperature(tempCommand, timeoutMs) {
|
|
|
13135
13246
|
};
|
|
13136
13247
|
}
|
|
13137
13248
|
}
|
|
13138
|
-
var execFileAsync$2, SCRIPT_NAME,
|
|
13249
|
+
var execFileAsync$2, SCRIPT_NAME, LHM_SUBDIR, LHM_RELEASE;
|
|
13139
13250
|
var init_wsl_temperature$1 = __esmMin((() => {
|
|
13140
13251
|
init_logger();
|
|
13141
13252
|
execFileAsync$2 = promisify(execFile);
|
|
13142
13253
|
SCRIPT_NAME = "cpu-temp.ps1";
|
|
13143
|
-
|
|
13254
|
+
LHM_SUBDIR = "home-hosted\\LibreHardwareMonitor";
|
|
13255
|
+
LHM_RELEASE = {
|
|
13256
|
+
version: "0.9.6",
|
|
13257
|
+
asset: "LibreHardwareMonitor.zip",
|
|
13258
|
+
/** From the release's asset `digest` field, `sha256:…`. */
|
|
13259
|
+
sha256: "086d9f1b5a99e643edc2cfaaac16051685b551e4c5ac0b32a57c58c0e529c001",
|
|
13260
|
+
url: "https://github.com/LibreHardwareMonitor/LibreHardwareMonitor/releases/download/v0.9.6/LibreHardwareMonitor.zip"
|
|
13261
|
+
};
|
|
13144
13262
|
}));
|
|
13145
13263
|
//#endregion
|
|
13146
13264
|
//#region src/api/wsl-temperature.ts
|
|
@@ -13208,6 +13326,17 @@ function createWslTemperatureRoute(deps) {
|
|
|
13208
13326
|
code: "SCRIPT_WRITE_FAILED"
|
|
13209
13327
|
});
|
|
13210
13328
|
}
|
|
13329
|
+
if (!lhmInstalled()) {
|
|
13330
|
+
if (c.req.query("download") !== "true") return c.json({
|
|
13331
|
+
...status(deps),
|
|
13332
|
+
needsDownload: true
|
|
13333
|
+
});
|
|
13334
|
+
const install = await installLibreHardwareMonitor();
|
|
13335
|
+
if (install.error !== null) throw new DetailedError(`LibreHardwareMonitor could not be installed: ${install.error}`, {
|
|
13336
|
+
statusCode: 400,
|
|
13337
|
+
code: "LIBRARY_INSTALL_FAILED"
|
|
13338
|
+
});
|
|
13339
|
+
}
|
|
13211
13340
|
const command = tempCommandFor(target);
|
|
13212
13341
|
const probe = await probeWslTemperature(command, 5e3);
|
|
13213
13342
|
if (probe.celsius === null) return c.json({
|
|
@@ -23139,13 +23268,13 @@ async function runSetupTemp(flags) {
|
|
|
23139
23268
|
if (!isWsl()) fail("--wsl is for a WSL2 guest, and this is not one. Run `setup-temp` with no flag to see the options");
|
|
23140
23269
|
const scriptPath = wslScriptPath();
|
|
23141
23270
|
if (scriptPath === null) fail("the Windows drive is not mounted, so the helper cannot be written where powershell.exe can read it");
|
|
23271
|
+
if (!lhmInstalled()) await offerLibreHardwareMonitor(flags);
|
|
23142
23272
|
writeWslTemperatureScript(scriptPath);
|
|
23143
23273
|
const command = tempCommandFor(scriptPath);
|
|
23144
23274
|
process.stdout.write(` helper ${dim(`${scriptPath} (${windowsScriptPath(scriptPath)} on Windows)`)}\n`);
|
|
23145
23275
|
const probe = await probeWslTemperature(command, 5e3);
|
|
23146
23276
|
if (probe.celsius === null) {
|
|
23147
23277
|
process.stdout.write(`${fail("not set up")} — the helper did not answer: ${probe.error ?? "unknown reason"}\n`);
|
|
23148
|
-
process.stdout.write(`${dim("install LibreHardwareMonitor in C:\\Tools\\LibreHardwareMonitor on Windows, then re-run this command")}\n`);
|
|
23149
23278
|
process.stdout.write(`${dim(`the script is at ${scriptPath}; the config was left unchanged`)}\n`);
|
|
23150
23279
|
return;
|
|
23151
23280
|
}
|
|
@@ -23158,6 +23287,30 @@ async function runSetupTemp(flags) {
|
|
|
23158
23287
|
process.stdout.write(` reading ${green(`${probe.celsius}°C`)}\n`);
|
|
23159
23288
|
}
|
|
23160
23289
|
}
|
|
23290
|
+
/**
|
|
23291
|
+
* Offer the ~6 MB download. A prompt, never a silent fetch: installing software nobody asked for is
|
|
23292
|
+
* not a setup command's job, and a non-interactive stdin answers no.
|
|
23293
|
+
*/
|
|
23294
|
+
async function offerLibreHardwareMonitor(flags) {
|
|
23295
|
+
const where = lhmDirectoryWindows() ?? "C:\\ProgramData\\home-hosted\\LibreHardwareMonitor";
|
|
23296
|
+
if (flags.download !== true) {
|
|
23297
|
+
if (flags.download === false) {
|
|
23298
|
+
process.stdout.write(`${dim(`LibreHardwareMonitor is not installed; install it into ${where}, or pass --download`)}\n`);
|
|
23299
|
+
return;
|
|
23300
|
+
}
|
|
23301
|
+
const answer = await prompt(`LibreHardwareMonitor is required to read the sensor. Download it now (~6 MB)? [y/N] `);
|
|
23302
|
+
if (!/^y(?:es)?$/i.test(answer.trim())) {
|
|
23303
|
+
process.stdout.write(`${dim(`left it alone — install it into ${where} and re-run this command`)}\n`);
|
|
23304
|
+
return;
|
|
23305
|
+
}
|
|
23306
|
+
}
|
|
23307
|
+
const result = await installLibreHardwareMonitor({ onProgress: (message) => process.stdout.write(` ${dim(message)}\n`) });
|
|
23308
|
+
if (result.error !== null) {
|
|
23309
|
+
process.stdout.write(`${fail("the download did not install")} — ${result.error}\n`);
|
|
23310
|
+
return;
|
|
23311
|
+
}
|
|
23312
|
+
process.stdout.write(` library ${green("installed")} in ${result.dir}\n`);
|
|
23313
|
+
}
|
|
23161
23314
|
var setupTempArgs, setupTempCommand;
|
|
23162
23315
|
var init_setup_temp = __esmMin((() => {
|
|
23163
23316
|
init_io();
|
|
@@ -23174,6 +23327,10 @@ var init_setup_temp = __esmMin((() => {
|
|
|
23174
23327
|
type: "boolean",
|
|
23175
23328
|
description: "stop using a configured command and delete its helper",
|
|
23176
23329
|
default: false
|
|
23330
|
+
},
|
|
23331
|
+
download: {
|
|
23332
|
+
type: "boolean",
|
|
23333
|
+
description: "download LibreHardwareMonitor without asking; --no-download never does (for a script)"
|
|
23177
23334
|
}
|
|
23178
23335
|
};
|
|
23179
23336
|
setupTempCommand = defineCommand({
|
|
@@ -23182,7 +23339,8 @@ var init_setup_temp = __esmMin((() => {
|
|
|
23182
23339
|
async run({ args }) {
|
|
23183
23340
|
await runSetupTemp({
|
|
23184
23341
|
wsl: args.wsl === true,
|
|
23185
|
-
clear: args.clear === true
|
|
23342
|
+
clear: args.clear === true,
|
|
23343
|
+
download: args.download
|
|
23186
23344
|
});
|
|
23187
23345
|
}
|
|
23188
23346
|
});
|
|
@@ -25002,6 +25160,7 @@ var SYNOPSIS = {
|
|
|
25002
25160
|
"free-port": "home-hosted free-port <id> [--workspace <id>]",
|
|
25003
25161
|
"set-password": "home-hosted set-password",
|
|
25004
25162
|
"set-token": "home-hosted set-token",
|
|
25163
|
+
"setup-temp": "home-hosted setup-temp [--wsl] [--download|--no-download] [--clear]",
|
|
25005
25164
|
"migrate": "home-hosted migrate",
|
|
25006
25165
|
"init": "home-hosted init",
|
|
25007
25166
|
"ui-switch": "home-hosted ui-switch",
|
|
@@ -25100,6 +25259,15 @@ var SET_TOKEN_SECTION = {
|
|
|
25100
25259
|
heading: "Options for set-token",
|
|
25101
25260
|
lines: [["--generate", "create a strong token and print it once"], ["--clear", "remove the token, so it stops working"]]
|
|
25102
25261
|
};
|
|
25262
|
+
var SETUP_TEMP_SECTION = {
|
|
25263
|
+
heading: "Options for setup-temp",
|
|
25264
|
+
lines: [
|
|
25265
|
+
["--wsl", "read the temperature through the Windows host (WSL2)"],
|
|
25266
|
+
["--download", "fetch LibreHardwareMonitor without asking (for a script)"],
|
|
25267
|
+
["--no-download", "never fetch it; report what is missing"],
|
|
25268
|
+
["--clear", "stop using the command and delete the helper"]
|
|
25269
|
+
]
|
|
25270
|
+
};
|
|
25103
25271
|
var MIGRATE_SECTION = {
|
|
25104
25272
|
heading: "Options for migrate",
|
|
25105
25273
|
lines: [["--dry-run", "print what would change, write nothing"], ["-y, --yes", "apply without asking (or set HHOSTED_MIGRATE=allow)"]]
|
|
@@ -25229,6 +25397,7 @@ var SECTIONS = {
|
|
|
25229
25397
|
"free-port": SERVER_SECTION,
|
|
25230
25398
|
"set-password": SET_PASSWORD_SECTION,
|
|
25231
25399
|
"set-token": SET_TOKEN_SECTION,
|
|
25400
|
+
"setup-temp": SETUP_TEMP_SECTION,
|
|
25232
25401
|
"migrate": MIGRATE_SECTION,
|
|
25233
25402
|
"init": INIT_SECTION,
|
|
25234
25403
|
"ui-switch": UI_SWITCH_SECTION,
|