#!/bin/bash
set -Eeuo pipefail
set -x

# stop service
systemctl stop containerd

# set proxy env variables
export HTTP_PROXY="${http_proxy}"
export HTTPS_PROXY="${https_proxy}"

# start up containerd
containerd &

# pull the "busybox" image from Docker Hub
ctr images pull docker.io/library/busybox:latest

# run it and capture the output
output="$(ctr run --rm docker.io/library/busybox:latest "test-$$-$RANDOM" echo success)"

# ensure the output was exactly what we expected
[ "$output" = 'success' ]
