Svelte: Expose more extensive configuration from the main WebVM component

This commit is contained in:
Alessandro Pignotti 2024-10-14 16:39:19 +02:00
parent bb46f1340e
commit f7fc244db4
4 changed files with 26 additions and 24 deletions

View file

@ -1,2 +1,23 @@
// The root filesystem location
export const diskImageUrl = "wss://disks.webvm.io/debian_large_20230522_5044875331.ext2";
// The root filesystem backend type
export const diskImageType = "cloud";
// Print an introduction message about the technology
export const printIntro = true;
// Is a graphical display needed
export const needsDisplay = false;
// Executable full path (Required)
export const cmd = "/bin/bash";
// Arguments, as an array (Required)
export const args = ["--login"];
// Optional extra parameters
export const opts = {
// Environment variables
env: ["HOME=/home/user", "TERM=xterm", "USER=user", "SHELL=/bin/bash", "EDITOR=vim", "LANG=en_US.UTF-8", "LC_ALL=C"],
// Current working directory
cwd: "/home/user",
// User id
uid: 1000,
// Group id
gid: 1000
};

View file

@ -64,6 +64,7 @@
consoleDiv.addEventListener("dragenter", preventDefaults, false);
consoleDiv.addEventListener("dragleave", preventDefaults, false);
consoleDiv.addEventListener("drop", preventDefaults, false);
if(configObj.printIntro)
printMessage(introMessage);
initCheerpX();
}
@ -133,30 +134,10 @@
cx.registerCallback("diskActivity", hddCallback);
term.scrollToBottom();
cxReadFunc = cx.setCustomConsole(writeData, term.cols, term.rows);
// Reasonable defaults for local deployments
// var cmd = "/bin/bash";
// var args = ["--login"];
// var env = ["HOME=/home/user", "TERM=xterm", "USER=user", "SHELL=/bin/bash", "EDITOR=vim", "LANG=en_US.UTF-8", "LC_ALL=C"];
// var cwd = "/home/user";
// Executable full path (Required)
var cmd = "/bin/bash";
// Arguments, as an array (Required)
var args = ["--login"]
// Optional extra parameters
var opts = {
// Environment variables
env: ["HOME=/home/user", "TERM=xterm", "USER=user", "SHELL=/bin/bash", "EDITOR=vim", "LANG=en_US.UTF-8", "LC_ALL=C"],
// Current working directory
cwd: "/home/user",
// User id
uid: 1000,
// Group id
gid: 1000
};
// Run the command in a loop, in case the user exits
while (true)
{
await cx.run(cmd, args, opts);
await cx.run(configObj.cmd, configObj.args, configObj.opts);
}
}
onMount(initTerminal);

View file

@ -1,6 +1,6 @@
<script>
import WebVM from '$lib/WebVM.svelte';
import * as configObj from 'config_terminal'
import * as configObj from '/config_terminal'
</script>
<WebVM configObj={configObj} />

View file

@ -5,7 +5,7 @@ import { viteStaticCopy } from 'vite-plugin-static-copy';
export default defineConfig({
resolve: {
alias: {
'config_terminal': 'config_public_terminal.js'
'/config_terminal': 'config_public_terminal.js'
}
},
build: {