system restores alias table...
parent
8c6ad8a72b
commit
6bee40d878
9
.system
9
.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"
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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<void> = functions[cmd as keyof typeof functions];
|
||||
|
|
|
|||
|
|
@ -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)) {
|
||||
|
|
|
|||
|
|
@ -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(' ');
|
||||
}
|
||||
Loading…
Reference in New Issue