feat: rebuild xiteng.site homelab platform

This commit is contained in:
2026-08-12 09:48:25 +08:00
parent 557b0eca33
commit 5b84988789
128 changed files with 14979 additions and 292 deletions
+19
View File
@@ -0,0 +1,19 @@
import {readFileSync} from "node:fs";
import {cloudflareRuleFromSpec, syncCloudflareRule} from "./controller.mjs";
const command = process.argv[2] || "plan";
const specPath = process.env.CLOUDFLARE_SPEC_PATH || "/state/cloudflare-cache-rules.json";
const tokenPath = process.env.CLOUDFLARE_API_TOKEN_FILE || "/run/secrets/cloudflare_cache_api_token";
const zoneId = process.env.CLOUDFLARE_ZONE_ID || "";
const spec = JSON.parse(readFileSync(specPath, "utf8"));
if (command === "plan") {
console.log(JSON.stringify(cloudflareRuleFromSpec(spec), null, 2));
} else if (["check", "apply"].includes(command)) {
const token = readFileSync(tokenPath, "utf8").trim();
const result = await syncCloudflareRule(spec, {zoneId, token, dryRun: command === "check"});
console.log(JSON.stringify(result, null, 2));
} else {
console.error("Usage: node cloudflare.mjs [plan|check|apply]");
process.exit(2);
}