diff --git a/.system b/.system index c97c966..484b223 100644 --- a/.system +++ b/.system @@ -2,7 +2,9 @@ "handoff": "invoke systemd boot", "instances": { "B7FFCD6C11974FC7A74509B6683D7420": { - "config": {}, + "config": { + "sshd": "invoke sshd start" + }, "module": "systemd" }, "600F5B3828BC4D78BCBA375596F6898B": { @@ -10,5 +12,8 @@ "module": "sshd" } }, - "aliases": {} + "aliases": { + "systemd": "B7FFCD6C11974FC7A74509B6683D7420", + "sshd": "600F5B3828BC4D78BCBA375596F6898B" + } } \ No newline at end of file diff --git a/src/commands/create.ts b/src/commands/create.ts index 707358f..b1f6b64 100644 --- a/src/commands/create.ts +++ b/src/commands/create.ts @@ -1,4 +1,5 @@ import { system, autoColorString } from '@kernel:base'; +import chalk from 'chalk'; import * as uuid from 'uuid'; export default async function create(module: string, name: string, id: string) { @@ -11,7 +12,7 @@ export default async function create(module: string, name: string, id: string) { // undefined means no paramter given. this is treated as a default alias // otherise, null should be to create anonymous instances. only addressable // by their creator or by discovery protocols to come soon... - name = name === undefined ? module : null; + name = name === undefined ? module : name; if(system.aliases.has(name)) { if(name === module) { throw new Error('DEFAULT_MODULE_ALREADY_EXISTS'); @@ -31,6 +32,10 @@ export default async function create(module: string, name: string, id: string) { if(name) { system.aliases.set(name, id); } - console.log('Created instance of', autoColorString(module)) + console.log('Created instance of', autoColorString(module)); + if(name) { + console.log(' Alias:', autoColorString(name)); + } + console.log(' Id:', chalk.ansi256(242)(id)); return id; } \ No newline at end of file diff --git a/src/commands/executor.ts b/src/commands/executor.ts index 3e61867..3894372 100644 --- a/src/commands/executor.ts +++ b/src/commands/executor.ts @@ -2,7 +2,6 @@ export default function createExecutor(functions: any) { return async function execute(...options: string[]) { - // console.log('λ', line); const [cmd, ...args] = options; if(cmd in functions) { const toInvoke: (...args: any[]) => void | Promise = functions[cmd as keyof typeof functions]; diff --git a/src/index.ts b/src/index.ts index 0ef76da..182988a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -66,7 +66,7 @@ export const kernel = { location = system.aliases.get(location); } if(!system.instances.has(location)) { - throw new Error('INVOCATION_TARGET_DOES_NOT_EXIST'); + throw new Error('INVOCATION_TARGET_DOES_NOT_EXIST: ' + location); } const instance = system.instances.get(location); if(!(fn in instance.functions)) { diff --git a/src/modules/systemd.ts b/src/modules/systemd.ts index 1809b47..896701c 100644 --- a/src/modules/systemd.ts +++ b/src/modules/systemd.ts @@ -1,5 +1,12 @@ -export default { - boot() { - console.log('systemd is being told to boot!'); +import { exec } from '@kernel:base'; + +export function boot() { + for(const [name, script] of Object.entries(this.config)) { + exec(script); } +} + +export function add(name: string, ...commandParts: string[]) { + this.config ??= {}; + this.config[name] = commandParts.join(' '); } \ No newline at end of file