diff options
| author | Dave Compton <davecompton7@gmail.com> | 2024-08-08 17:13:08 -0700 |
|---|---|---|
| committer | Dave Compton <davecompton7@gmail.com> | 2024-08-10 14:54:19 -0700 |
| commit | 3ff9340be1cd9d9fcd76c0f0324f0f39deee7563 (patch) | |
| tree | 63fdfbcd049c6104fe466ed6a53977c10217f34c /set_digitalocean_dns_a_record.bash | |
| parent | f65df2752535a26b6b99afabca3b77aef6659c4a (diff) | |
initial
Diffstat (limited to 'set_digitalocean_dns_a_record.bash')
| -rwxr-xr-x | set_digitalocean_dns_a_record.bash | 47 |
1 files changed, 0 insertions, 47 deletions
diff --git a/set_digitalocean_dns_a_record.bash b/set_digitalocean_dns_a_record.bash deleted file mode 100755 index f795894..0000000 --- a/set_digitalocean_dns_a_record.bash +++ /dev/null @@ -1,47 +0,0 @@ -#! /bin/bash -SCRIPT="${BASH_SOURCE[0]}" -SCRIPT_DIR=${SCRIPT%/*} - -DIGITALOCEAN_DOMAIN=$1 -IP=$2 - -DIGITALOCEAN_TOKEN=`cat $SCRIPT_DIR/DO_TOKEN` - -get_a_record_ids() { - curl -X GET \ - -H "Content-Type: application/json" \ - -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \ - "https://api.digitalocean.com/v2/domains/$DIGITALOCEAN_DOMAIN/records" 2> /dev/null | jq '.domain_records | map(select(.type == "A" and .name == "@")) | map(.id) | .[]' -} - -add_a_record() { - echo adding new A record for $DIGITALOCEAN_DOMAIN with value : $IP - curl -X POST \ - -H "Content-Type: application/json" \ - -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \ - -d "{\"type\":\"A\" \ - ,\"name\":\"@\" \ - ,\"data\":\"$IP\" \ - ,\"priority\":null \ - ,\"port\":null \ - ,\"ttl\":1800 \ - ,\"weight\":null \ - ,\"flags\":null \ - ,\"tag\":null \ - }" \ - "https://api.digitalocean.com/v2/domains/$DIGITALOCEAN_DOMAIN/records" > /dev/null 2>&1 -} - -delete_record_by_id() { - echo deleting existing A record for $DIGITALOCEAN_DOMAIN - curl -X DELETE \ - -H "Content-Type: application/json" \ - -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \ - "https://api.digitalocean.com/v2/domains/$DIGITALOCEAN_DOMAIN/records/$1" > /dev/null 2>&1 -} - -for s in `get_a_record_ids`; do - delete_record_by_id $s -done - -add_a_record |
