# /opt/libvirt-driver/prepare.sh
currentDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
source ${currentDir}/base.sh # Get variables from base script.
# trap any error, and mark it as a system failure.
trap "exit $SYSTEM_FAILURE_EXIT_CODE" ERR
# Copy base disk to use for Job.
qemu-img create -f qcow2 -b "$BASE_VM_IMAGE" "$VM_IMAGE"
echo 'Waiting for VM to get IP'
if [ "$i" == "30" ]; then
echo 'Waited 30 seconds for VM to start, exiting...'
# Inform GitLab Runner that this is a system failure, so it
exit "$SYSTEM_FAILURE_EXIT_CODE"
# Wait for ssh to become available
echo "Waiting for sshd to be available"
if ssh -i /root/.ssh/id_rsa -o StrictHostKeyChecking=no [email protected]"$VM_IP" >/dev/null 2>/dev/null; then if [ "$i" == "30" ]; then
echo 'Waited 30 seconds for sshd to start, exiting...'
# Inform GitLab Runner that this is a system failure, so it
exit "$SYSTEM_FAILURE_EXIT_CODE"