This commit is contained in:
randogoth 2025-10-26 17:02:43 +02:00
parent 43b9d9f47a
commit 8f8779fee1
4 changed files with 29 additions and 2 deletions

View file

@ -10,6 +10,7 @@ COPY scripts/dos-shell /usr/local/bin/dos-shell
COPY scripts/dos-httpd /usr/local/bin/dos-httpd
COPY scripts/prepare-svardos.sh /usr/local/bin/prepare-svardos
COPY scripts/start-services.sh /usr/local/bin/start-dos-services
COPY WebPlus_IBM_VGA_8x16.woff /usr/local/share/dos-httpd/WebPlus_IBM_VGA_8x16.woff
RUN chmod +x /usr/local/bin/dos-shell /usr/local/bin/dos-httpd /usr/local/bin/start-dos-services /usr/local/bin/prepare-svardos && echo "/usr/local/bin/dos-shell" >> /etc/shells
# Create sshd runtime directory

View file

@ -126,6 +126,7 @@ You can override which binary is used for the Linux side by setting `DOS_LINUX_S
| `DOS_SSH_PORT` | `2222` | Host port forwarded to container port 22. |
| `DOS_TELNET_PORT` | `2323` | Host port forwarded to container port 23. |
| `DOS_HTTP_PORT` | `8080` | Host port forwarded to the web console. |
| `DOS_HTTP_FONT_PATH` | `/usr/local/share/dos-httpd/WebPlus_IBM_VGA_8x16.woff` | Override the font served to the web console. |
| `ENABLE_TELNET` | `1` | Toggle BusyBox telnetd. |
| `ENABLE_HTTP_CONSOLE` | `1` | Launch the built-in web terminal. |
| `TELNET_PORT` | `23` | Port inside the container where telnetd listens. |

View file

@ -36,12 +36,17 @@ HTML_PAGE = """<!DOCTYPE html>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/xterm@5.3.0/css/xterm.css" />
<style>
@font-face {
font-family: "DOSVGA";
src: url("/assets/WebPlus_IBM_VGA_8x16.woff") format("woff");
font-display: swap;
}
:root, body { background: #1e1e1e; color: #f0f0f0; height: 100%; }
body {
margin: 0;
display: flex;
flex-direction: column;
font-family: system-ui, sans-serif;
font-family: "DOSVGA", "Fira Code", "Cascadia Mono", "Hack", monospace;
}
header {
padding: 0.6rem 1rem;
@ -70,6 +75,8 @@ HTML_PAGE = """<!DOCTYPE html>
const term = new Terminal({
cursorBlink: true,
convertEol: true,
fontFamily: "DOSVGA, Fira Code, Cascadia Mono, Hack, monospace",
fontSize: 16,
theme: {
background: "#000000",
foreground: "#f5f5f5"
@ -315,6 +322,13 @@ async def health_handler(_request: web.Request) -> web.Response:
return web.Response(text="ok\n", content_type="text/plain")
async def font_handler(request: web.Request) -> web.StreamResponse:
cfg: "AppConfig" = request.app["config"]
if not cfg.font_path or not os.path.exists(cfg.font_path):
raise web.HTTPNotFound()
return web.FileResponse(path=cfg.font_path, headers={"Cache-Control": "public, max-age=86400"})
async def websocket_handler(request: web.Request) -> web.WebSocketResponse:
ws = web.WebSocketResponse(heartbeat=30)
await ws.prepare(request)
@ -347,13 +361,14 @@ async def websocket_handler(request: web.Request) -> web.WebSocketResponse:
class AppConfig:
def __init__(self, user: str, shell_path: str, host: str, port: int, rows: int, cols: int):
def __init__(self, user: str, shell_path: str, host: str, port: int, rows: int, cols: int, font_path: Optional[str]):
self.user = user
self.shell_path = shell_path
self.host = host
self.port = port
self.default_rows = rows
self.default_cols = cols
self.font_path = font_path
def build_argument_parser() -> argparse.ArgumentParser:
@ -378,6 +393,11 @@ def build_argument_parser() -> argparse.ArgumentParser:
choices=["CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG"],
help="Log verbosity",
)
parser.add_argument(
"--font-path",
default=os.environ.get("DOS_HTTP_FONT_PATH", "/usr/local/share/dos-httpd/WebPlus_IBM_VGA_8x16.woff"),
help="Path to the WOFF font used by the terminal UI",
)
return parser
@ -392,6 +412,7 @@ async def create_app(cfg: AppConfig) -> web.Application:
[
web.get("/", index_handler),
web.get("/healthz", health_handler),
web.get("/assets/WebPlus_IBM_VGA_8x16.woff", font_handler),
web.get("/ws", websocket_handler),
]
)
@ -410,6 +431,7 @@ def main() -> None:
port=args.port,
rows=args.rows,
cols=args.cols,
font_path=args.font_path if args.font_path else None,
)
app = asyncio.run(create_app(cfg))

View file

@ -113,6 +113,9 @@ start_http_console() {
if [ -n "${DOS_HTTP_LOG_LEVEL:-}" ]; then
args+=(--log-level "${DOS_HTTP_LOG_LEVEL}")
fi
if [ -n "${DOS_HTTP_FONT_PATH:-}" ]; then
args+=(--font-path "${DOS_HTTP_FONT_PATH}")
fi
set +e
"${DOS_HTTPD_BIN}" "${args[@]}" &