-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathprovision-digitalocean.sh
More file actions
executable file
·40 lines (31 loc) · 1 KB
/
provision-digitalocean.sh
File metadata and controls
executable file
·40 lines (31 loc) · 1 KB
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
#!/bin/bash
# Adapted from https://inlets.dev
export SUFFIX=$(head -c 16 /dev/urandom | shasum | cut -c1-8)
export DROPLETNAME="of-workshop-$SUFFIX"
export SIZE="s-2vcpu-4gb"
export IMAGE="ubuntu-16-04-x64"
export REGION="lon1"
export FIELDS="ID,Name,PublicIPv4"
export USERDATA=`pwd`/cloudinit.txt
echo "Creating: $DROPLETNAME"
dropletInfo="$(doctl compute droplet create $DROPLETNAME \
--size $SIZE \
--image $IMAGE \
--region $REGION \
--user-data-file $USERDATA \
--format "$FIELDS" \
--no-header \
--wait \
)"
if [ $? -eq 0 ];
then
readfields=$(sed 's/,/ /g' <<<$FIELDS)
read -r $readfields <<<"$dropletInfo"
echo "=============================="
echo "Droplet: $Name has been created"
echo "IP: $PublicIPv4"
echo "URL: https://$PublicIPv4:8443"
echo "Login: ssh root@$PublicIPv4"
echo "=============================="
echo "To destroy this droplet run: doctl compute droplet delete -f $ID"
fi