Example scripts

Example scripts that you can use in your lifecycle scripts.

Track setup scripts

Wait for bootstrap

Wait for the Instruqt bootstrap process to complete.

#!/bin/bash
set -euxo pipefail

until [ -f /opt/instruqt/bootstrap/host-bootstrap-completed ]; do
    echo "Waiting for instruqt bootstrap to complete"    sleep 1
done

The bootstrap process may overwrite user files like .bashrc. Wait is encouraged!

Wait for service

Wait for a specific web service in your setup script to finish booting.

while ! curl --fail --output /dev/null https://<hostname>:<port>/<path> 
do
    sleep 1
done

Create a file

Create a file using heredoc method.

You can append to a file by using >> as opposed to >.

Download files

Download files to the local system.

Start background process

Start a process in the background so your script does not hang.

Challenge check scripts

File exists

Check if a file exists:

File doesn't exist

Check if a file doesn't exist (or is not a file):

Directory exists

Check if a directory exists:

Directory doesn't exist

Use the following code in your life cycle script to check if a folder doesn't exist (or is not a directory)

File contains certain text

Check if a file contains certain text.

Specific command is installed

Check that a specific command is executable with the -x flag.

Service is running

Check if a service is running.

Replace SERVICE with a service name running on that system.

Last updated

Was this helpful?