#!/bin/bash set -e mkdir -p test-in-vm if [[ ! -f test/certs/pebble.minica.pem ]]; then if ! which minica > /dev/null; then cat <<'EOF' >&2 minica is not installed; install by following: https://github.com/jsha/minica/blob/v1.1.0/README.md#installation and ensuring ~/go/bin is in your PATH. Do *not* use the minica from apt/apt-get, that is a completely separate program. EOF exit 1 elif [[ "$(minica --help 2>&1)" =~ $'\n'' '*'-domains ' ]]; then (cd test/certs; minica -ca-alg RSA -ca-cert pebble.minica.pem -ca-key pebble.minica.key.pem -domains localhost,pebble -ip-addresses 127.0.0.1) else cat <<'EOF' >&2 you have the wrong minica installed; run `sudo apt uninstall minica` then install the correct one by following: https://github.com/jsha/minica/blob/v1.1.0/README.md#installation and ensuring ~/go/bin is in your PATH. Do *not* use the minica from apt/apt-get, that is a completely separate program. EOF exit 1 fi fi if ! which pebble > /dev/null; then cat <<'EOF' >&2 pebble is not installed; install either using `sudo apt install pebble` or by following: https://github.com/letsencrypt/pebble/blob/v2.6.0/README.md#install and ensuring ~/go/bin is in your PATH. EOF exit 1 fi PEBBLE_VA_NOSLEEP=1 pebble -config test/config/pebble-config.json -strict false& # intentionally capture the PID now, since otherwise it will be lost by the time the trap runs # shellcheck disable=SC2064 trap "kill $!" EXIT sleep 1 CURL_CA_BUNDLE=test/certs/pebble.minica.pem curl https://127.0.0.1:15000/roots/0 -o test/certs/cur-root.crt rm -f test-in-vm/index GIT_INDEX_FILE=test-in-vm/index git add . GIT_INDEX_FILE=test-in-vm/index git add -f test/certs/pebble.minica.pem test/certs/cur-root.crt commit_tree="$(GIT_INDEX_FILE=test-in-vm/index git write-tree)" commit="$(git commit-tree -m "commit created by test-in-vm.sh" "$commit_tree")" echo "commit: $commit" virsh snapshot-revert libre-chip.test --snapshotname start sleep 1 ssh root@libre-chip.test bash -c ':; hwclock --hctosys; rm -rf ~/test-in-vm; mkdir ~/test-in-vm; cd ~/test-in-vm; git init' git push root@libre-chip.test:test-in-vm "$commit":refs/tags/test-in-vm ssh root@libre-chip.test bash -c ':; cd ~/test-in-vm; git checkout test-in-vm; ./setup.sh --test' read -p 'press enter to terminate acme server and exit'