From f8cd5ba2e5faf46cc63cef03a64603af89b46d8a Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Mon, 1 May 2023 14:29:47 -0400 Subject: [PATCH] Remove bash script version --- zoneupdate.sh | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 zoneupdate.sh diff --git a/zoneupdate.sh b/zoneupdate.sh deleted file mode 100644 index 716da85..0000000 --- a/zoneupdate.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -APIKEY="$(awk 'BEGIN {RS="\n"; FS="\t";}{if($1=="APIKEY"){print $2}}' /etc/zoneupdate.conf)" -DOMAIN="$(awk 'BEGIN {RS="\n"; FS="\t";}{if($1=="DOMAIN"){print $2}}' /etc/zoneupdate.conf)" -subdomainList=(@ "$(awk 'BEGIN {RS="\n"; FS="\t";}{if($1=="SUBDOMAIN"){print $2}}' /etc/zoneupdate.conf)") -OLD_IP="$(awk 'BEGIN {RS="\n"; FS="\t";}{if($1=="IP"){print $2}}' /etc/zoneupdate.conf)" -NEW_IP=$(curl -4 -s icanhazip.com) - - -if [[ "${OLD_IP}" != "${NEW_IP}" ]]; then - for subdomain in ${subdomainList[@]}; do - RESP=$(curl -s -X PUT -H "Content-Type: application/json" \ - -H "X-Api-Key: $APIKEY" \ - -d '{"items": [{"rrset_type": "A", - "rrset_ttl": 3600, - "rrset_values":["'$NEW_IP'"]}]}' \ - https://dns.api.gandi.net/api/v5/domains/$DOMAIN/records/$subdomain) - [[ "${RESP}" != '{"message": "DNS Record Created"}' ]] && ERROR=true - done - [[ "${ERROR}" != "true" ]] && { gawk -i inplace -v IP="${NEW_IP}" 'BEGIN {RS="\n"; FS="\t"; OFS="\t"}{if($1=="IP"){$2=IP}{print $0}}' /etc/zoneupdate.conf; exit 0; } || { echo ${RESP}; exit 1; } -else - exit 0 -fi -