vm_create () { doctl compute droplet create "$1" \ --image ubuntu-22-04-x64 \ --size s-1vcpu-512mb-10gb \ --ssh-keys 28174738 --ssh-keys 28964182 --ssh-keys 28963526 \ --region nyc1 \ --wait } vm_get_ip () { IP=null while [[ $IP == null ]]; do NETWORKS=`doctl compute droplet get "$1" -o json | jq --args '.[0].networks.v4'` if [[ $NETWORKS != null ]]; then IP=`echo $NETWORKS | jq -r --args '.[] | select(.type!="private") | .ip_address'` else sleep 1 fi done } vm_destroy () { doctl compute droplet delete "$1" -f } dropletId=$(openssl rand -hex 8) vm_create "$dropletId" vm_get_ip "$dropletId" results=$(ssh -o StrictHostKeyChecking=no "root@$IP" ' curl -s "https://shared.danrh.co.uk/example.json" curl -s "https://shared.danrh.co.uk/example.json" curl -s "https://shared.danrh.co.uk/example.json" curl -s "https://shared.danrh.co.uk/example.json" ') vm_destroy "$dropletId" echo "$results"