summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordan <[email protected]>2023-09-19 20:39:57 -0400
committerdan <[email protected]>2023-09-19 20:39:57 -0400
commitccd930ce580dd4adb21d879c1a15e66660e3a0fe (patch)
tree3d7e970dc055a9e184dfe6b858e4c77b83a1c046
parent5a5e2dd05623aad71d8343a5de0480cd8756f85b (diff)
downloaddump-master.tar.gz
dump-master.tar.bz2
dump-master.zip
feat: add run-command-on-many-different-vps.shHEADmaster
-rw-r--r--run-command-on-many-different-vps.sh42
1 files changed, 42 insertions, 0 deletions
diff --git a/run-command-on-many-different-vps.sh b/run-command-on-many-different-vps.sh
new file mode 100644
index 0000000..024bc87
--- /dev/null
+++ b/run-command-on-many-different-vps.sh
@@ -0,0 +1,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"