Commands¶
Run these from the pack directory, the directory that contains trylab.
prereqs¶
Installs the build tools and writes firecracker into the pack directory. It prints the name of each package before installing it. QEMU is the program that builds the disk. Packer drives that build. apt asks for your password. The command expects Linux amd64. At the end it checks that this account can use /dev/kvm.
trylab asks when one of these programs is missing. One missing program asks Install it with ./prereqs? [y/N]. More than one asks Install them with ./prereqs? [y/N]. Answering y or yes runs this command. Any other answer, including Enter, leaves them uninstalled. With no terminal, trylab stops and names what is missing.
The login key¶
trylab logs in as root with the private key ssh-key in the pack directory. A build writes that file when it is missing.
Build a disk¶
trylab builds a missing disk before the lab starts. The shared disk is filesystems/default.ext4. A lab with its own disk gets filesystems/<lab>.ext4.
It builds again when it had to write a new ssh-key over a disk that was already there.
A lab that uses another disk, including default, is not built again.
The first build of any disk also writes the kernel and the initrd, the small filesystem that mounts the disk at boot. Later builds reuse both.
The build needs the network. setup.sh runs during the build, as root, after files from data/ have been unpacked to /root/data/.
trylab¶
With a lab directory, trylab checks that index.md exists. When ssh-key is missing, it writes that key. When the lab's disk is missing, it says the file does not exist and asks Build it now? [Y/n]. Press Enter, or answer y, to build the disk. n leaves the disk unbuilt. With no terminal, the note is printed and the build starts. For a lab with snapshot: true, it writes a snapshot when the one on disk is missing or out of date, then opens the lab. It prints:
Open that address. The banner is the lab's title. The page has the lesson, the shell, and a link for each service.
With no argument, trylab starts the local catalog at http://127.0.0.1:8080 and waits. Ctrl-C stops it, and stops a lab the same way.
sudo is required because trylab creates the lab network. The machine's address on that network is 172.16.0.2.
sudo drops variables unless you keep them. Set the name in your shell, then:
Under sudo, trylab starts from root's environment. A file at /root/.config/runlab/lab-env replaces any name it contains. The file runlabctl writes for your own account is a different file. Secrets describes it.
The shared machine¶
The default disk is Ubuntu. These are installed:
- Docker (
docker.io) - curl, ca-certificates, jq, tree, vim
- bat (also as
bat, when the package installedbatcat) - yq
- zellij
- bash completion, an OpenSSH server, and common compression tools
A lab with no setup.sh and no data/ file boots this disk. Docker is available. An image the lesson pulls still has to be downloaded, and that download needs the network.