feat: 支持证书托管和节点自动安装
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import path from "node:path";
|
||||
import { decryptText } from "@/lib/crypto";
|
||||
import type { Installation } from "@/lib/provisioning";
|
||||
const quote = (value: string) => "'" + value.replaceAll("'", "'\\''") + "'";
|
||||
export function buildInstallScript(job: Installation) {
|
||||
const token = decryptText(job.token_encrypted);
|
||||
if (!token) throw new Error("installation_token_unavailable");
|
||||
const values: Record<string, string> = {
|
||||
PANEL: job.origin,
|
||||
TOKEN: token,
|
||||
INSTALL_ID: job.id,
|
||||
SLUG: job.slug,
|
||||
};
|
||||
return readFileSync(
|
||||
path.join(process.cwd(), "lib/templates/install-node.sh"),
|
||||
"utf8",
|
||||
).replace(/__(PANEL|TOKEN|INSTALL_ID|SLUG)__/g, (_, key) =>
|
||||
quote(values[key]),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user