2021-10-01 01:44:50 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
import fs from 'fs';
|
|
|
|
import path from 'path';
|
|
|
|
|
2022-01-09 16:30:42 +00:00
|
|
|
import log from '../../lib/io/NamespacedLog.mjs'; const l = log("agent");
|
|
|
|
|
2021-10-01 01:44:50 +00:00
|
|
|
import settings from '../../settings.mjs';
|
2022-01-08 16:59:08 +00:00
|
|
|
import toml_settings_read from '../../lib/io/TomlSettings.mjs';
|
|
|
|
|
2022-01-23 19:51:23 +00:00
|
|
|
import SystemQuery from '../../lib/SystemQuery.mjs';
|
2022-01-08 16:59:08 +00:00
|
|
|
|
|
|
|
// HACK: Make sure __dirname is defined when using es6 modules. I forget where I found this - a PR with a source URL would be great :D
|
|
|
|
const __dirname = import.meta.url.slice(7, import.meta.url.lastIndexOf("/"));
|
2021-10-01 01:44:50 +00:00
|
|
|
|
|
|
|
export default async function () {
|
2022-01-08 16:59:08 +00:00
|
|
|
if(!fs.existsSync(settings.cli.config))
|
2022-01-09 16:30:42 +00:00
|
|
|
throw new Error(`Error: The config file at '${settings.cli.config}' doesn't appear to exist, or we don't have permission to access it.`);
|
|
|
|
|
2022-01-23 19:51:23 +00:00
|
|
|
console.error(`
|
2022-01-09 16:30:42 +00:00
|
|
|
███████ ██ ██ ███████ ████████ ███████ ███ ███ ██████ ██ ██ ███████ ██████ ██ ██
|
|
|
|
██ ██ ██ ██ ██ ██ ████ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██
|
|
|
|
███████ ████ ███████ ██ █████ ██ ████ ██ ██ ██ ██ ██ █████ ██████ ████
|
|
|
|
██ ██ ██ ██ ██ ██ ██ ██ ██ ▄▄ ██ ██ ██ ██ ██ ██ ██
|
|
|
|
███████ ██ ███████ ██ ███████ ██ ██ ██████ ██████ ███████ ██ ██ ██
|
|
|
|
▀▀`);
|
2022-01-08 16:59:08 +00:00
|
|
|
|
|
|
|
let config = toml_settings_read(
|
|
|
|
path.join(__dirname, "config.default.toml"),
|
|
|
|
settings.cli.config
|
|
|
|
);
|
|
|
|
|
2022-01-23 19:51:23 +00:00
|
|
|
// Returns the systemquery instance, but we don't actually need it here
|
|
|
|
await SystemQuery.Create(config);
|
2021-10-01 01:44:50 +00:00
|
|
|
}
|