26 lines
830 B
JavaScript
26 lines
830 B
JavaScript
/**
|
|
* Hyperdrive-resident kernel (staged as /boot/init.js).
|
|
* Loaded by the booter with an injected ctx object (trusted replication source).
|
|
*/
|
|
async function start(ctx) {
|
|
const { console, drive, readLine, execLine, b4a } = ctx
|
|
const rel = await drive.get('/etc/os-release')
|
|
if (rel) console.log(b4a.toString(rel))
|
|
console.log(
|
|
'Bare operating system — session: guest (login [--new] <passphrase> to unlock identity) | shell: cd, export, exit, login, logout | try: help, ls /bin, pwd, crontab -l'
|
|
)
|
|
while (true) {
|
|
const line = await readLine('')
|
|
if (line == null) break
|
|
const t = line.trim()
|
|
if (t === '') continue
|
|
let status = 'ok'
|
|
try {
|
|
status = await execLine(t)
|
|
} catch (e) {
|
|
console.error((e && e.message) || String(e))
|
|
}
|
|
if (status === 'exit') break
|
|
}
|
|
}
|