aboutsummaryrefslogtreecommitdiffstats
path: root/bin/domain_to_current_ip
blob: 9c6d96209c23dc93909d5624365497de2b1c6b94 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
#!/usr/bin/env bash

set -eou pipefail

[ ! type -p dig &>/dev/null ] && echo "Install dig." && exit 1
[ ! type -p gandi &>/dev/null ] && echo "Install gandi.cli." && exit 1
[ $# -ne 1 ] && "Domain name required as argument." && exit 1

current_ip=$(dig +short myip.opendns.com @resolver1.opendns.com)
gandi dns update --ttl 3600 "$1" @ A "$current_ip"

exit 0