Mount + proper init + sys/proc/tmp
This commit is contained in:
@@ -1 +1,3 @@
|
||||
syscall.node
|
||||
syscall.node
|
||||
ioctl.node
|
||||
mount.node
|
||||
@@ -6,4 +6,4 @@ module.exports = (path) => {
|
||||
const data = fs.readFileSync(path)
|
||||
fs.writeFileSync(audiopath, data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
|
||||
//@ts-check
|
||||
function panic() {
|
||||
console.log("/!\\ INIT PANIK /!\\ LOSE CHIBRE")
|
||||
@@ -6,15 +7,12 @@ function panic() {
|
||||
|
||||
async function main() {
|
||||
try {
|
||||
const audio = require('./audio.js')
|
||||
const initd = require('./initd.js')
|
||||
const reboot = require('./reboot.js')
|
||||
const input = require('./input.js')
|
||||
const { fHook } = require("./hook.js")
|
||||
|
||||
console.log("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n")
|
||||
console.clear()
|
||||
console.log(`
|
||||
|
||||
|
||||
_______ _________ ______ _______ _______
|
||||
( ____ \\|\\ /|\\__ __/( ___ \\ ( ____ )( ___ )|\\ /|
|
||||
| ( \\/| ) ( | ) ( | ( ) )| ( )|| ( ) |( \\ / )
|
||||
@@ -35,7 +33,7 @@ async function main() {
|
||||
|
||||
`)
|
||||
|
||||
audio('/chibrax/sheeebr.wav')
|
||||
await initd()
|
||||
|
||||
//chainload into sheebr
|
||||
await fHook("/usr/bin/sheebr.js")
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
//@ts-check
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
/**
|
||||
* @typedef {{ name: string, before: string[], after: string[], init(): undefined | Promise<undefined> }} InitScript
|
||||
*/
|
||||
async function init() {
|
||||
|
||||
const initdFiles = fs.readdirSync('/etc/init.d/')
|
||||
const initdScripts = initdFiles.filter( (v) => v.endsWith('.js'))
|
||||
|
||||
/**
|
||||
* @type { Array<String> }
|
||||
*/
|
||||
const finishedScripts = []
|
||||
|
||||
/**
|
||||
* @type { Array<InitScript> }
|
||||
*/
|
||||
const scripts = []
|
||||
|
||||
for(const script of initdScripts) {
|
||||
const scriptCandidate = require(path.join('/etc/init.d/', script))
|
||||
if(scriptCandidate?.before && scriptCandidate?.after && scriptCandidate?.init)
|
||||
scripts.push({ ...scriptCandidate, name: script})
|
||||
else
|
||||
console.error(`Invalid(missing exports) script error :${script}`)
|
||||
}
|
||||
|
||||
const befores = processBefores(scripts)
|
||||
|
||||
let i = 0
|
||||
while(scripts.length) {
|
||||
const s = scripts[i % scripts.length]
|
||||
i += 1
|
||||
if(isSubSet(s.after, finishedScripts) && ( !befores[s.name] || isSubSet(befores[s.name], finishedScripts) )) {
|
||||
//on supprime ce service
|
||||
scripts.splice(scripts.indexOf(s))
|
||||
|
||||
const result = s.init()
|
||||
if(typeof result?.then === 'function') {
|
||||
await result
|
||||
}
|
||||
finishedScripts.push(s.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @param {Array<T>} arraya
|
||||
* @param {Array<T>} arrayb
|
||||
*/
|
||||
function isSubSet(arraya, arrayb) {
|
||||
for(const a of arraya) {
|
||||
if(!arrayb.includes(a)) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {Array<InitScript>} scripts
|
||||
* @returns {{ [key: string]: string[] }}
|
||||
*/
|
||||
function processBefores(scripts) {
|
||||
/**
|
||||
* @type {{ [key: string]: string[] }}
|
||||
*/
|
||||
const result = {}
|
||||
for(const script of scripts) {
|
||||
for(const before of script.before){
|
||||
if(! result[before]) result[before] = [script.name]
|
||||
else result[before].push(script.name)
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
module.exports = init
|
||||
@@ -1,7 +0,0 @@
|
||||
const fs = require('fs')
|
||||
|
||||
function setLayOut(layout) {
|
||||
|
||||
}
|
||||
|
||||
fs.readFileSync('/etc/vconsole.conf')
|
||||
@@ -0,0 +1,68 @@
|
||||
//@ts-check
|
||||
const fs =require('fs')
|
||||
/**
|
||||
* @type {{ mount: (device_path: string, mount_point: string, fs: string, flags: number, fsparams: string ) => number }}
|
||||
*///@ts-expect-error
|
||||
const nodemount = require("./mount.node")
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
const cmount = nodemount.mount
|
||||
|
||||
|
||||
/* These are the fs-independent mount-flags: up to 16 flags are
|
||||
supported */
|
||||
const flags = {
|
||||
MS_RDONLY: 1, /* Mount read-only. */
|
||||
MS_NOSUID: 2, /* Ignore suid and sgid bits. */
|
||||
MS_NODEV: 4, /* Disallow access to device special files. */
|
||||
MS_NOEXEC: 8, /* Disallow program execution. */
|
||||
MS_SYNCHRONOUS: 16, /* Writes are synced at once. */
|
||||
MS_REMOUNT: 32, /* Alter flags of a mounted FS. */
|
||||
MS_MANDLOCK: 64, /* Allow mandatory locks on an FS. */
|
||||
MS_DIRSYNC: 128, /* Directory modifications are synchronous. */
|
||||
MS_NOATIME: 1024, /* Do not update access times. */
|
||||
MS_NODIRATIME: 2048, /* Do not update directory access times. */
|
||||
MS_BIND: 4096, /* Bind directory at different place. */
|
||||
MS_MOVE: 8192,
|
||||
MS_REC: 16384,
|
||||
MS_SILENT: 32768,
|
||||
MS_POSIXACL: 1 << 16, /* VFS does not apply the umask. */
|
||||
MS_UNBINDABLE: 1 << 17, /* Change to unbindable. */
|
||||
MS_PRIVATE: 1 << 18, /* Change to private. */
|
||||
MS_SLAVE: 1 << 19, /* Change to slave. */
|
||||
MS_SHARED: 1 << 20, /* Change to shared. */
|
||||
MS_RELATIME: 1 << 21, /* Update atime relative to mtime/ctime. */
|
||||
MS_KERNMOUNT: 1 << 22, /* This is a kern_mount call. */
|
||||
MS_I_VERSION: 1 << 23, /* Update inode I_version field. */
|
||||
MS_STRICTATIME: 1 << 24, /* Always perform atime updates. */
|
||||
MS_LAZYTIME: 1 << 25, /* Update the on-disk [acm]times lazily. */
|
||||
MS_ACTIVE: 1 << 30,
|
||||
MS_NOUSER: 1 << 31
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} devicePath
|
||||
* @param {string} mountPoint
|
||||
* @param {string} fstype
|
||||
* @param {number} flags
|
||||
* @param {string} fsparams
|
||||
* @returns {number}
|
||||
*/
|
||||
function mount(devicePath, mountPoint, fstype, flags, fsparams) {
|
||||
const supportedFilesystems = require('./suportedFilesystems')
|
||||
|
||||
const filesystem = supportedFilesystems.find( v => v.name === fstype)
|
||||
if(! filesystem) {
|
||||
throw "Invalid filesystem"
|
||||
}
|
||||
|
||||
if(! fs.existsSync(devicePath) && filesystem.hasdev)
|
||||
throw "Device don't exist"
|
||||
return cmount(devicePath, mountPoint, fstype, flags, fsparams)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
module.exports = { mount, cmount, flags }
|
||||
@@ -0,0 +1,9 @@
|
||||
//@ts-check
|
||||
const fs = require('fs')
|
||||
|
||||
const systems = fs.readFileSync('/proc/filesystems', { encoding: 'utf-8' }).split('\n')
|
||||
|
||||
const filesystems = systems.map(s => ({ hasdev: !s.includes('nodev'), name: s.includes('nodev') ? s.split('nodev')[1].trim() : s.trim() }))
|
||||
|
||||
module.exports = filesystems
|
||||
Object.freeze(module.exports)
|
||||
Reference in New Issue
Block a user