summaryrefslogtreecommitdiffstats
path: root/bin/helpers/launch-mail2
blob: 38176d7ff190a8119d7c744676503e7860c2bd82 (plain) (blame)
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
#!/usr/bin/env bash
set -eu
set -o pipefail

# shellcheck source=functions.sh
. "$(dirname "$0")/functions.sh"

create_droplet mail2.tozt.net s-1vcpu-1gb 0812b69f-dde4-11eb-9b7e-0a58ac1465ad

echo "Creating DNS entry for $ip..."
record_id=$(
    doctl \
        -t "$(cat /mnt/digitalocean)" \
        compute domain records list \
        tozt.net \
        --format Name,Type,ID \
        --no-header |
        grep '^smtp2 \+A ' |
        awk '{print $3}'
)
doctl \
    -t "$(cat /mnt/digitalocean)" \
    compute domain records update \
    tozt.net \
    --record-id "$record_id" \
    --record-type A \
    --record-name smtp2 \
    --record-data "$ip" \
    --record-ttl 600
echo "Done creating DNS entry"

provision_droplet mail2

echo "Done"