|
56 | 56 |
|
57 | 57 | varemulator=newV86Starter(options);
|
58 | 58 |
|
| 59 | +functioninitTerm(){ |
| 60 | +constfitAddon=newFitAddon.FitAddon(); |
| 61 | +emulator.serial_adapter.term.loadAddon(fitAddon); |
| 62 | +fitAddon.fit(); |
| 63 | +window.addEventListener("resize",()=>fitAddon.fit()); |
| 64 | +} |
| 65 | + |
| 66 | +functionsendBackgroundCommands(commands){ |
| 67 | +constfilename=`${(Math.random()+1).toString(36).substring(7)}.sh` |
| 68 | +emulator.create_file(`/inbox/${filename}`,(newTextEncoder('UTF-8')).encode(commands.join("\n"))); |
| 69 | +} |
| 70 | + |
59 | 71 | if(!boot){
|
60 | 72 | emulator.add_listener("emulator-ready",function(){
|
61 |
| -constfitAddon=newFitAddon.FitAddon(); |
62 |
| -emulator.serial_adapter.term.loadAddon(fitAddon); |
63 |
| -fitAddon.fit(); |
64 |
| -window.addEventListener("resize",()=>fitAddon.fit()); |
65 |
| -// emulator.serial_adapter.term.setOption("allowTransparency", true); |
66 |
| -// emulator.serial_adapter.term.setOption("theme", { background: "transparent" }); |
| 73 | +initTerm(); |
67 | 74 | setTimeout(()=>{
|
68 |
| -emulator.serial0_send('/etc/init.d/S40network restart\n'); |
69 |
| -emulator.serial0_send('psql -U postgres\n'); |
70 |
| -emulator.serial0_send('\\! echo "boot_completed"; reset\n'); |
| 75 | +sendBackgroundCommands(["/etc/init.d/S40network restart"]); |
| 76 | +emulator.serial0_send('\\! reset\n'); |
| 77 | +emulator.serial_adapter.term.focus(); |
71 | 78 | },0);
|
72 | 79 | });
|
73 |
| - |
74 |
| -functionhandleBoot(line){ |
75 |
| -if(line.startsWith("postgres=# boot_completed")){ |
76 |
| -emulator.remove_listener(handleBoot); |
77 |
| -setTimeout(()=>{ |
78 |
| -emulator.serial_adapter.term.focus(); |
79 |
| -},300); |
80 |
| -} |
81 |
| -} |
82 |
| -emulator.add_listener("serial0-output-line",handleBoot); |
83 | 80 | }
|
84 | 81 |
|
85 | 82 | varstate;
|
|