lots of news
parent
2f5cb8d272
commit
956ac726e1
|
|
@ -0,0 +1,4 @@
|
|||
create systemd
|
||||
create sshd
|
||||
systemd add sshd exec sshd start
|
||||
set handoff invoke systemd boot
|
||||
|
|
@ -3,12 +3,16 @@
|
|||
"version": "1.0.0",
|
||||
"main": "index.js",
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"start": "(clear || cls) && ts-node ./src/index.ts"
|
||||
"start": "(clear || cls) && node --loader ts-node/esm ./src/index.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/node": "^16.11.12",
|
||||
"chalk": "^5.0.0",
|
||||
"serverline": "^1.5.0",
|
||||
"ssh2": "^1.5.0",
|
||||
"telnet": "^0.0.1",
|
||||
"ts-node": "^10.4.0",
|
||||
"typescript": "^4.5.3"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import createExecutor from "./executor";
|
||||
import createExecutor from "./executor.js";
|
||||
|
||||
export const create = createExecutor({
|
||||
pawn() {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
|
||||
|
||||
|
||||
export default function createExecutor(functions: any) {
|
||||
return function execute(...options: string[]) {
|
||||
// console.log('λ', line);
|
||||
|
|
@ -8,6 +7,8 @@ export default function createExecutor(functions: any) {
|
|||
if(cmd in functions) {
|
||||
const toInvoke: (...args: any[]) => void = functions[cmd as keyof typeof functions];
|
||||
toInvoke(...args);
|
||||
} else {
|
||||
console.log('Unknown command', cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
75
src/index.ts
75
src/index.ts
|
|
@ -1,30 +1,83 @@
|
|||
/// <reference path="./externals.d.ts" />
|
||||
|
||||
import * as serverline from 'serverline';
|
||||
import createExecutor from './commands/executor';
|
||||
import { create } from './commands/create';
|
||||
import './logHook.js';
|
||||
import serverline from 'serverline';
|
||||
import createExecutor from './commands/executor.js';
|
||||
import { create } from './commands/create.js';
|
||||
import { readFileSync, writeFileSync } from 'fs';
|
||||
import { resolve } from 'path'
|
||||
import chalk from 'chalk';
|
||||
|
||||
console.clear();
|
||||
|
||||
// const system = {
|
||||
|
||||
// }
|
||||
const args = process.argv.slice(2);
|
||||
const [ startupFile ] = args;
|
||||
|
||||
type Instance = any;
|
||||
|
||||
const system = {
|
||||
instances: new Map<string, Instance>(),
|
||||
handoff: ''
|
||||
}
|
||||
|
||||
export const exec = (s: string, echo = true) => {
|
||||
if(echo) console.log(chalk.cyan('@ ') + chalk.ansi256(242)(s));
|
||||
executor(...(s.split(' ')));
|
||||
};
|
||||
|
||||
serverline.init({
|
||||
prompt: 'λ '
|
||||
prompt: chalk.cyan('λ ')
|
||||
});
|
||||
// serverline.setCompletion(['help', 'command1', 'command2', 'login', 'check', 'ping'])
|
||||
|
||||
const executor = createExecutor({
|
||||
create: create,
|
||||
create(module: string, name: string) {
|
||||
console.log(s);
|
||||
},
|
||||
quit() {
|
||||
console.log('Shutting down');
|
||||
process.exit(0)
|
||||
serverline.close();
|
||||
process.exit(0);
|
||||
},
|
||||
ls(flags: any) {
|
||||
if(flags) console.log(flags)
|
||||
|
||||
console.log('Instances (' + system.instances.size + ')');
|
||||
for(const [k, v] of system.instances) {
|
||||
console.log(' ' + k + ':', v);
|
||||
}
|
||||
},
|
||||
save() {
|
||||
const timeStart = new Date().getTime();
|
||||
const systemString = JSON.stringify(system, null, 2);
|
||||
const fullPath = resolve('.system');
|
||||
writeFileSync(fullPath, systemString);
|
||||
const elapsed = new Date().getTime() - timeStart;
|
||||
console.log('System saved to ' + fullPath + ' in ' + elapsed + ' ms')
|
||||
},
|
||||
reset() {
|
||||
system.handoff = '';
|
||||
system.instances = new Map();
|
||||
console.log('System has been reset.');
|
||||
},
|
||||
exec: exec,
|
||||
invoke(...a: any[]) {
|
||||
console.log(a);
|
||||
}
|
||||
});
|
||||
|
||||
serverline.on('line', (s: string) => executor(...(s.split(' '))))
|
||||
serverline.on('line', (a: string) => {
|
||||
exec(a, false);
|
||||
})
|
||||
|
||||
serverline.on('SIGINT', () => {
|
||||
executor('quit');
|
||||
exec('quit');
|
||||
});
|
||||
|
||||
if(startupFile) {
|
||||
const fullPath = resolve(startupFile);
|
||||
const lines = readFileSync(fullPath).toString().split('\n').map(v => v.trim());
|
||||
for(const line of lines) {
|
||||
exec(line);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
|
||||
import { appendFileSync } from 'fs'
|
||||
import { EventEmitter } from 'events'
|
||||
|
||||
const events = new EventEmitter();
|
||||
|
||||
process.stdout.write = (function(write): any {
|
||||
return function(string: string, encoding: any, fileDescriptor: any) {
|
||||
// const ansiCodes = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g;
|
||||
// appendFileSync('.log', string);
|
||||
events.emit('data', string);
|
||||
write.apply(process.stdout, arguments);
|
||||
};
|
||||
})(process.stdout.write);
|
||||
|
||||
|
||||
export default events;
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
export default class pawn {
|
||||
constructor() {
|
||||
|
||||
export default {
|
||||
tick() {
|
||||
console.log('I am a pawn, and i have ticked!');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
import telnet from 'telnet';
|
||||
|
||||
import { exec } from '@kernel';
|
||||
|
||||
export default {
|
||||
start() {
|
||||
var telnet = require('telnet')
|
||||
|
||||
telnet.createServer(function (client) {
|
||||
|
||||
// make unicode characters work properly
|
||||
client.do.transmit_binary()
|
||||
|
||||
// make the client emit 'window size' events
|
||||
client.do.window_size()
|
||||
|
||||
// listen for the window size events from the client
|
||||
client.on('window size', function (e) {
|
||||
if (e.command === 'sb') {
|
||||
console.log('telnet window resized to %d x %d', e.width, e.height)
|
||||
}
|
||||
})
|
||||
|
||||
// listen for the actual data from the client
|
||||
client.on('data', function (b) {
|
||||
exec(b);
|
||||
client.write(b)
|
||||
})
|
||||
|
||||
client.write('connected to Telnet server!')
|
||||
|
||||
}).listen(23)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
export default {
|
||||
boot() {
|
||||
console.log('systemd is being told to boot!');
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,13 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"noImplicitAny": true,
|
||||
"downlevelIteration": true
|
||||
"downlevelIteration": true,
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "Node",
|
||||
"baseUrl": "./",
|
||||
"paths": {
|
||||
"@kernel": [ "src/index.ts" ]
|
||||
}
|
||||
},
|
||||
"include": [
|
||||
"src/index.ts"
|
||||
|
|
|
|||
98
yarn.lock
98
yarn.lock
|
|
@ -54,11 +54,64 @@ arg@^4.1.0:
|
|||
resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089"
|
||||
integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==
|
||||
|
||||
asn1@^0.2.4:
|
||||
version "0.2.6"
|
||||
resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.2.6.tgz#0d3a7bb6e64e02a90c0303b31f292868ea09a08d"
|
||||
integrity sha512-ix/FxPn0MDjeyJ7i/yoHGFt/EX6LyNbxSEhPPXODPL+KB0VPk86UYfL0lMdy+KCnv+fmvIzySwaK5COwqVbWTQ==
|
||||
dependencies:
|
||||
safer-buffer "~2.1.0"
|
||||
|
||||
bcrypt-pbkdf@^1.0.2:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz#a4301d389b6a43f9b67ff3ca11a3f6637e360e9e"
|
||||
integrity sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=
|
||||
dependencies:
|
||||
tweetnacl "^0.14.3"
|
||||
|
||||
binary@*:
|
||||
version "0.3.0"
|
||||
resolved "https://registry.yarnpkg.com/binary/-/binary-0.3.0.tgz#9f60553bc5ce8c3386f3b553cff47462adecaa79"
|
||||
integrity sha1-n2BVO8XOjDOG87VTz/R0Yq3sqnk=
|
||||
dependencies:
|
||||
buffers "~0.1.1"
|
||||
chainsaw "~0.1.0"
|
||||
|
||||
buffers@*, buffers@~0.1.1:
|
||||
version "0.1.1"
|
||||
resolved "https://registry.yarnpkg.com/buffers/-/buffers-0.1.1.tgz#b24579c3bed4d6d396aeee6d9a8ae7f5482ab7bb"
|
||||
integrity sha1-skV5w77U1tOWru5tmorn9Ugqt7s=
|
||||
|
||||
chainsaw@~0.1.0:
|
||||
version "0.1.0"
|
||||
resolved "https://registry.yarnpkg.com/chainsaw/-/chainsaw-0.1.0.tgz#5eab50b28afe58074d0d58291388828b5e5fbc98"
|
||||
integrity sha1-XqtQsor+WAdNDVgpE4iCi15fvJg=
|
||||
dependencies:
|
||||
traverse ">=0.3.0 <0.4"
|
||||
|
||||
chalk@^5.0.0:
|
||||
version "5.0.0"
|
||||
resolved "https://registry.yarnpkg.com/chalk/-/chalk-5.0.0.tgz#bd96c6bb8e02b96e08c0c3ee2a9d90e050c7b832"
|
||||
integrity sha512-/duVOqst+luxCQRKEo4bNxinsOQtMP80ZYm7mMqzuh5PociNL0PvmHFvREJ9ueYL2TxlHjBcmLCdmocx9Vg+IQ==
|
||||
|
||||
cpu-features@0.0.2:
|
||||
version "0.0.2"
|
||||
resolved "https://registry.yarnpkg.com/cpu-features/-/cpu-features-0.0.2.tgz#9f636156f1155fd04bdbaa028bb3c2fbef3cea7a"
|
||||
integrity sha512-/2yieBqvMcRj8McNzkycjW2v3OIUOibBfd2dLEJ0nWts8NobAxwiyw9phVNS6oDL8x8tz9F7uNVFEVpJncQpeA==
|
||||
dependencies:
|
||||
nan "^2.14.1"
|
||||
|
||||
create-require@^1.1.0:
|
||||
version "1.1.1"
|
||||
resolved "https://registry.yarnpkg.com/create-require/-/create-require-1.1.1.tgz#c1d7e8f1e5f6cfc9ff65f9cd352d37348756c333"
|
||||
integrity sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==
|
||||
|
||||
debug@*:
|
||||
version "4.3.3"
|
||||
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.3.tgz#04266e0b70a98d4462e6e288e38259213332b664"
|
||||
integrity sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==
|
||||
dependencies:
|
||||
ms "2.1.2"
|
||||
|
||||
diff@^4.0.1:
|
||||
version "4.0.2"
|
||||
resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d"
|
||||
|
|
@ -69,11 +122,51 @@ make-error@^1.1.1:
|
|||
resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2"
|
||||
integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==
|
||||
|
||||
ms@2.1.2:
|
||||
version "2.1.2"
|
||||
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009"
|
||||
integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==
|
||||
|
||||
nan@^2.14.1, nan@^2.15.0:
|
||||
version "2.15.0"
|
||||
resolved "https://registry.yarnpkg.com/nan/-/nan-2.15.0.tgz#3f34a473ff18e15c1b5626b62903b5ad6e665fee"
|
||||
integrity sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ==
|
||||
|
||||
safer-buffer@~2.1.0:
|
||||
version "2.1.2"
|
||||
resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a"
|
||||
integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==
|
||||
|
||||
serverline@^1.5.0:
|
||||
version "1.5.0"
|
||||
resolved "https://registry.yarnpkg.com/serverline/-/serverline-1.5.0.tgz#d483a7b3dcd598e68685cd6b4cf28e22e08f8723"
|
||||
integrity sha512-QzNBH8omGchv+L5n/irZEeU2IGK3r8EMRh3EKRIlbfTklf9PtNRiRbWcYr8kqdNeWdc5M5jS13VtspDKgFXFFg==
|
||||
|
||||
ssh2@^1.5.0:
|
||||
version "1.5.0"
|
||||
resolved "https://registry.yarnpkg.com/ssh2/-/ssh2-1.5.0.tgz#4dc559ba98a1cbb420e8d42998dfe35d0eda92bc"
|
||||
integrity sha512-iUmRkhH9KGeszQwDW7YyyqjsMTf4z+0o48Cp4xOwlY5LjtbIAvyd3fwnsoUZW/hXmTCRA3yt7S/Jb9uVjErVlA==
|
||||
dependencies:
|
||||
asn1 "^0.2.4"
|
||||
bcrypt-pbkdf "^1.0.2"
|
||||
optionalDependencies:
|
||||
cpu-features "0.0.2"
|
||||
nan "^2.15.0"
|
||||
|
||||
telnet@^0.0.1:
|
||||
version "0.0.1"
|
||||
resolved "https://registry.yarnpkg.com/telnet/-/telnet-0.0.1.tgz#db164465c551a99ee785ea7fbba5a67cfc26c4af"
|
||||
integrity sha1-2xZEZcVRqZ7nhep/u6WmfPwmxK8=
|
||||
dependencies:
|
||||
binary "*"
|
||||
buffers "*"
|
||||
debug "*"
|
||||
|
||||
"traverse@>=0.3.0 <0.4":
|
||||
version "0.3.9"
|
||||
resolved "https://registry.yarnpkg.com/traverse/-/traverse-0.3.9.tgz#717b8f220cc0bb7b44e40514c22b2e8bbc70d8b9"
|
||||
integrity sha1-cXuPIgzAu3tE5AUUwisui7xw2Lk=
|
||||
|
||||
ts-node@^10.4.0:
|
||||
version "10.4.0"
|
||||
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.4.0.tgz#680f88945885f4e6cf450e7f0d6223dd404895f7"
|
||||
|
|
@ -92,6 +185,11 @@ ts-node@^10.4.0:
|
|||
make-error "^1.1.1"
|
||||
yn "3.1.1"
|
||||
|
||||
tweetnacl@^0.14.3:
|
||||
version "0.14.5"
|
||||
resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64"
|
||||
integrity sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=
|
||||
|
||||
typescript@^4.5.3:
|
||||
version "4.5.3"
|
||||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.5.3.tgz#afaa858e68c7103317d89eb90c5d8906268d353c"
|
||||
|
|
|
|||
Loading…
Reference in New Issue