initial commit

This commit is contained in:
2025-11-16 15:57:18 +01:00
parent f97b165008
commit edd6c028e5
21 changed files with 673 additions and 15 deletions

34
src/index.ts Normal file
View File

@@ -0,0 +1,34 @@
import { readFile } from "node:fs/promises";
import { join } from "node:path";
import { getMqttClient } from "./clients/mqtt/mqtt-client";
import { ConfigSchema } from "./config.schema";
import { EfiBootMgrService } from "./efibootmgr.service";
import { startListeners } from "./listener";
import { logger } from "./logger";
import { runPublishLoop } from "./publisher";
logger.info("Starting intialization...");
const configsFolder = process.env.CONFIGS_PATH || "./";
const fileContent = await readFile(
join(configsFolder, "efibootmgr.config.json"),
{
encoding: "utf8",
},
).catch((e) => {
throw new Error("Error while reading config!", { cause: e });
});
const json = JSON.parse(fileContent);
const config = ConfigSchema.parse(json);
const efiBootMgrService = new EfiBootMgrService();
const bootEntries = await efiBootMgrService.listBootEntries();
const mqttClient = await getMqttClient(config.mqtt);
runPublishLoop(config, mqttClient, bootEntries);
startListeners(config, mqttClient);