blob: 024bc8706673ddd4854615d1b076c371aaf7e48a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
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"
|