Helper scripts
When bootstrapping any sandbox container or virtual machine, we inject a couple of helper scripts. These functions assist you in setting up the environment, or when writing check scripts. You can view the currently available set of scripts here: https://github.com/instruqt/participant-host-bootstrap/tree/master/bootstrap/bin/functions.
These helper scripts assume the container or virtual machine have a POSIX shell available at /bin/sh.

fail-message

The fail-message script can be used to provide feedback to the learner when writing check scripts. The function will write a given string to stdout, prefixed with FAIL:. See Challenge check for more details on writing check scripts.
1
#!/bin/bash
2
# check
3
echo "Checking the solution of the challenge"
4
if [ !$EVERYTHING_WENT_WELL ]; then
5
fail-message "Your challenge failed because of [REASON]"
6
# which is equivalent to
7
echo "FAIL: Your challenge failed because of [REASON]"
8
exit 1
9
fi
Copied!

set-workdir

The set-workdir script can be used to change the active working directory for a terminal tab.
The set-workdir script is implemented using $HOME/.bashrc. This means you'll have to use bash as the shell for the container or virtual machine.
If you don't have bash available, you can achieve the same behavior by adding a cd /path/to/workdir command to the shell's profile (e.g. $HOME/.profile or /etc/profile).
When using the ash shell (which most busybox based containers do), you can also indicate that the .bashrc profile needs to be loaded. To do so, add an environment variable ENV with value $HOME/.bashrc. to the container's environment variables in the config.yml.
Last modified 6mo ago
Copy link