diff --git a/src/emulator/src/main.js b/src/emulator/src/main.js index 67f2daf55..8a0492994 100644 --- a/src/emulator/src/main.js +++ b/src/emulator/src/main.js @@ -110,6 +110,23 @@ puter.ui.on('connection', event => { window.onload = async function() { + let emu_config; try { + emu_config = await puter.fs.read('config.json'); + } catch (e) {} + + if ( ! emu_config ) { + await puter.fs.write('config.json', JSON.stringify({})); + emu_config = {}; + } + + if ( emu_config instanceof Blob ) { + emu_config = await emu_config.text(); + } + + if ( typeof emu_config === 'string' ) { + emu_config = JSON.parse(emu_config); + } + const resp = await fetch( './image/build/rootfs.bin' ); @@ -152,10 +169,14 @@ window.onload = async function() // bzimage_initrd_from_filesystem: true, autostart: true, - network_relay_url: "wisp://127.0.0.1:3000", + network_relay_url: emu_config.network_relay ?? "wisp://127.0.0.1:3000", virtio_console: true, }); + emulator.add_listener('download-error', function(e) { + status.missing_files || (status.missing_files = []); + status.missing_files.push(e.file_name); + }); const decoder = new TextDecoder(); const byteStream = NewCallbackByteStream(); diff --git a/src/phoenix/src/puter-shell/providers/EmuCommandProvider.js b/src/phoenix/src/puter-shell/providers/EmuCommandProvider.js index 81f90cea3..3c2257c2a 100644 --- a/src/phoenix/src/puter-shell/providers/EmuCommandProvider.js +++ b/src/phoenix/src/puter-shell/providers/EmuCommandProvider.js @@ -36,6 +36,19 @@ export class EmuCommandProvider { if ( conn.response.status.ready ) { p_ready.resolve(); } + console.log('status from emu', conn.response); + if ( conn.response.status.missing_files ) { + const pfx = '\x1B[31;1m┃\x1B[0m '; + ctx.externs.out.write('\n'); + ctx.externs.out.write('\x1B[31;1m┃ Emulator is missing files:\x1B[0m\n'); + for (const file of conn.response.status.missing_files) { + ctx.externs.out.write(pfx+`- ${file}\n`); + } + ctx.externs.out.write(pfx+'\n'); + ctx.externs.out.write(pfx+'\x1B[33;1mDid you run `./tools/build_v86.sh`?\x1B[0m\n'); + ctx.externs.out.write('\n'); + return; + } console.log('awaiting emulator ready'); ctx.externs.out.write('Waiting for emulator...\n'); await p_ready;