initialize generic rms-software repository

Add the reusable RMS core application (server, web UI, plugins, tests, tools) with generic defaults, GPL licensing, and maintainer context documentation so deployments can consume this repo as software source independent of station-specific overlays.
This commit is contained in:
2026-03-16 03:31:08 +01:00
commit e1a4ce0b8b
58 changed files with 20611 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
const fs = require("fs");
const path = require("path");
async function createPlugin(ctx) {
return {
async execute(action) {
if (action !== "getTxState") {
throw new Error(`Unknown action: ${action}`);
}
return readTxState(ctx);
},
async getStatus() {
return readTxState(ctx);
},
async health() {
return { ok: true };
}
};
}
function readTxState(ctx) {
const stateFilePath = resolvePath(String(ctx.getSetting("stateFilePath", ctx.env.TX_STATE_PATH || "./data/tx-state.json")));
const fallback = {
txActive: false,
source: "tx-state-file",
updatedAt: null,
path: stateFilePath
};
if (!stateFilePath || !fs.existsSync(stateFilePath)) {
return fallback;
}
try {
const raw = fs.readFileSync(stateFilePath, "utf8");
const parsed = JSON.parse(raw);
return {
txActive: Boolean(parsed && parsed.txActive),
source: "tx-state-file",
updatedAt: parsed && parsed.updatedAt ? parsed.updatedAt : null,
path: stateFilePath,
details: parsed && typeof parsed === "object" ? parsed : null
};
} catch {
return fallback;
}
}
function resolvePath(value) {
const v = String(value || "").trim();
if (!v) return "";
if (path.isAbsolute(v)) return v;
return path.resolve(process.cwd(), v);
}
module.exports = {
createPlugin
};