Reorganisation de tout le systéme de build + debuggage os loader au autre scripts
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//@ts-check
|
||||
const { exec, fork } = require('child_process');
|
||||
const { exec, fork, spawn } = require('child_process');
|
||||
/**
|
||||
* @param {string} path
|
||||
* @deprecated
|
||||
@@ -20,4 +20,33 @@ async function fHook(path) {
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = { hookTo, fHook }
|
||||
/**
|
||||
* @param { string } cmd
|
||||
* @param { import('child_process').SpawnOptionsWithoutStdio } [option]
|
||||
*/
|
||||
async function spawnAndWait(cmd, option) {
|
||||
const child = spawn(cmd, option)
|
||||
|
||||
child.stdout.pipe(process.stdout)
|
||||
child.stderr.pipe(process.stderr)
|
||||
process.stdin.pipe(child.stdin)
|
||||
|
||||
await new Promise((res, rej) => {
|
||||
child.on('exit', () => {
|
||||
res()
|
||||
})
|
||||
})
|
||||
process.stdin.unpipe(child.stdin)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param { string } path
|
||||
* @param { string[] } [args]
|
||||
* @param { import('child_process').SpawnOptionsWithoutStdio } [options]
|
||||
*/
|
||||
async function startjs(path, args = [], options = {}) {
|
||||
const arguments = args.map(arg => {return arg.includes(' ') ? `"${arg}"` : arg}).join(' ')
|
||||
return spawnAndWait(`/usr/local/bin/node ${path} ${arguments}`, options)
|
||||
}
|
||||
|
||||
module.exports = { hookTo, fHook, spawnAndWait, startjs }
|
||||
@@ -1,5 +1,6 @@
|
||||
|
||||
//@ts-check
|
||||
const fs = require('fs')
|
||||
|
||||
function panic() {
|
||||
console.log("/!\\ INIT PANIK /!\\ LOSE CHIBRE")
|
||||
while(1) {}
|
||||
@@ -16,7 +17,11 @@ async function main() {
|
||||
await initd()
|
||||
|
||||
//chainload into sheebr
|
||||
await fHook("/usr/bin/sheebr.js")
|
||||
if(fs.existsSync("/usr/bin/sheebr.js")) {
|
||||
await fHook("/usr/bin/sheebr.js")
|
||||
} else {
|
||||
console.log('wrong shell path')
|
||||
}
|
||||
reboot.disableCtrlAltSupr()
|
||||
reboot.powerOff()
|
||||
|
||||
|
||||
@@ -40,4 +40,15 @@ function getFlags(interface) {
|
||||
return ip.getFlags(interface);
|
||||
}
|
||||
|
||||
module.exports = { setFlags, getFlags, flags }
|
||||
/**
|
||||
* @param { string } interface
|
||||
* @param { Uint8Array } address
|
||||
*/
|
||||
function setIpv4(interface, address) {
|
||||
if( address.length !== 4) {
|
||||
throw new Error('invalid address length');
|
||||
}
|
||||
ip.setIpv4(interface, address.join('.'));
|
||||
}
|
||||
|
||||
module.exports = { setFlags, getFlags, setIpv4, flags }
|
||||
Reference in New Issue
Block a user