Repository navigation
Expand file tree
/
Copy pathlinux-lab-embed.html
More file actions
72 lines (71 loc) · 3.2 KB
/
Copy pathlinux-lab-embed.html
File metadata and controls
72 lines (71 loc) · 3.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>CodeLab — Real Linux Shell Lab</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@innovatorved/code-lab@0.8.0/dist/code-lab.css" />
<style>
html, body, #lab { margin: 0; padding: 0; width: 100%; height: 100vh; }
</style>
</head>
<body>
<div id="lab"></div>
<!--
Serve alpine.erofs from your own origin with HTTP Range support:
npx -p @innovatorved/code-lab@0.8.0 codelab-fetch-unkernel --out public/linux
The unkernel SDK itself loads from the pinned jsDelivr build unless you pass `sdkUrl`.
-->
<script src="https://cdn.jsdelivr.net/npm/@innovatorved/code-lab@0.8.0/dist/code-lab.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@innovatorved/code-lab@0.8.0/dist/extensions/linux.js"></script>
<script>
window.CodeLab.mount('#lab', {
id: 'linux-permissions-lab',
title: 'Files & Permissions',
mode: 'guided',
lang: 'sh',
settings: { 'workbench.colorTheme': 'dark', 'terminal.fontSize': 14 },
steps: [
{
id: 'explore',
title: 'Find the log file',
instructions: [
'A web server left a log in `/lab/logs`. List it with `ls -l /lab/logs`.',
'Copy `access.log` into your workspace (the terminal starts in `/workspace`): `cp /lab/logs/access.log .`'
],
hint: '`cp /lab/logs/access.log /workspace/` works from any directory.',
setup: 'mkdir -p /lab/logs && printf "GET / 200\\nGET /admin 403\\nGET /api 200\\n" > /lab/logs/access.log',
check: 'test -f /workspace/access.log || { echo "access.log is not in /workspace yet"; exit 1; }'
},
{
id: 'count',
title: 'Count the 200s',
instructions: 'Edit `count.sh` so it prints how many lines of `access.log` contain ` 200`, then run `sh count.sh`.',
hint: '`grep -c " 200" access.log`',
targetFile: 'count.sh',
check: 'out="$(cd /workspace && sh count.sh 2>&1)"; [ "$out" = "2" ] || { echo "count.sh printed: $out (expected 2)"; exit 1; }'
},
{
id: 'perms',
title: 'Make it executable',
instructions: 'Run `chmod +x count.sh` and then `./count.sh`.',
check: 'test -x /workspace/count.sh || { echo "count.sh is not executable yet"; exit 1; }'
}
],
shStarterFiles: {
'count.sh': '#!/bin/sh\n# TODO: print the number of lines in access.log containing " 200"\n',
'README.md': '# Files & Permissions\n\nThis terminal is a real Linux kernel running in your browser.\nTry `uname -a`, `ps`, `top` or `vi count.sh`.\n'
},
shSolutionFiles: {
'count.sh': '#!/bin/sh\ngrep -c " 200" access.log\n'
},
extensions: [
window.CodeLabLinux.linuxExtension({
distroUrl: '/linux/alpine.erofs',
onStatus: function (e) { console.log('[linux]', e.status, e.problems || e.error || ''); }
})
]
});
</script>
</body>
</html>