summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2018-10-15 23:47:06 -0400
committerJesse Luehrs <doy@tozt.net>2018-10-15 23:47:06 -0400
commit51722cfaf0e0a852e440173152f822b155af328f (patch)
tree123a0b80fb0802ee758c69128e0089267a5652a6 /bin
parentcf70bdcd8951fa0784cc0cac2115c1840840f2ac (diff)
downloadpuppet-tozt-51722cfaf0e0a852e440173152f822b155af328f.tar.gz
puppet-tozt-51722cfaf0e0a852e440173152f822b155af328f.zip
start refactoring some of my scripts
Diffstat (limited to 'bin')
-rwxr-xr-xbin/helpers/launch-tozt28
-rwxr-xr-xbin/launch33
2 files changed, 37 insertions, 24 deletions
diff --git a/bin/helpers/launch-tozt b/bin/helpers/launch-tozt
new file mode 100755
index 0000000..06dc07d
--- /dev/null
+++ b/bin/helpers/launch-tozt
@@ -0,0 +1,28 @@
+#!/usr/bin/env bash
+set -eu
+set -o pipefail
+
+echo "Creating droplet for tozt..."
+id=$(doctl compute droplet create \
+ tozt \
+ --image debian-9-x64 \
+ --region nyc3 \
+ --size s-1vcpu-1gb \
+ --ssh-keys 23160354 \
+ --volumes 4206344e-cf4f-11e8-a5a7-0a58ac1465db \
+ --format ID \
+ --no-header \
+ --wait)
+echo "Created droplet with id $id"
+
+echo "Assigning floating ip to tozt..."
+# XXX this returns an error for some reason, but actually succeeds:
+# Error: could not assign IP to droplet: json: cannot unmarshal number
+# 2328181259 into Go struct field Action.resource_id of type int
+doctl compute floating-ip-action assign 138.197.58.11 "$id" || true
+echo "Done assigning floating ip"
+
+echo "Provisioning droplet..."
+"$(dirname "$0")/bootstrap"
+
+echo "Done"
diff --git a/bin/launch b/bin/launch
index 06dc07d..1bbd8dc 100755
--- a/bin/launch
+++ b/bin/launch
@@ -2,27 +2,12 @@
set -eu
set -o pipefail
-echo "Creating droplet for tozt..."
-id=$(doctl compute droplet create \
- tozt \
- --image debian-9-x64 \
- --region nyc3 \
- --size s-1vcpu-1gb \
- --ssh-keys 23160354 \
- --volumes 4206344e-cf4f-11e8-a5a7-0a58ac1465db \
- --format ID \
- --no-header \
- --wait)
-echo "Created droplet with id $id"
-
-echo "Assigning floating ip to tozt..."
-# XXX this returns an error for some reason, but actually succeeds:
-# Error: could not assign IP to droplet: json: cannot unmarshal number
-# 2328181259 into Go struct field Action.resource_id of type int
-doctl compute floating-ip-action assign 138.197.58.11 "$id" || true
-echo "Done assigning floating ip"
-
-echo "Provisioning droplet..."
-"$(dirname "$0")/bootstrap"
-
-echo "Done"
+case "$1" in
+ tozt)
+ "$(dirname "$0")"/helpers/launch-tozt
+ ;;
+ *)
+ echo "unknown host $1" >&2
+ exit 1
+ ;;
+esac