Added namecheap agent

This commit is contained in:
Eric Renfro 2023-10-31 12:12:01 -04:00
parent 0f27928920
commit 70ae63f97a
Signed by: psi-jack
GPG key ID: 14977F3A50D9A5BF
2 changed files with 74 additions and 0 deletions

View file

@ -0,0 +1,69 @@
#!/bin/bash
# Internal Initialization
source "${DIP_FUNCTIONS}"
if [[ -r "${DIP_BASE_DIR}/conf.d/${DIP_AGENT_NAME}.conf" ]]; then
source "${DIP_BASE_DIR}/conf.d/${DIP_AGENT_NAME}.conf"
fi
if [[ -r "${DIP_BASE_DIR}/conf.d/${DIP_AGENT_EXEC}.conf" ]]; then
source "${DIP_BASE_DIR}/conf.d/${DIP_AGENT_EXEC}.conf"
fi
if [[ -z "$agent_update_dns_r53_id" ]]; then
logerr "ERROR: Need 'agent_update_dns_r53_id' to be defined to your Route53 Domain ID"
exit 99
fi
#if [[ -d "${DIP_BASE_DIR}/aws" ]]; then
# if [[ ! -r "${DIP_BASE_DIR}/aws/config" ]]; then
# logerr "ERROR: AWS config file not found: '${DIP_BASE_DIR}/aws/config'"
# exit 99
# elif [[ ! -r "${DIP_BASE_DIR}/aws/credentials" ]]; then
# logerr "ERROR: AWS credentials file not found: '${DIP_BASE_DIR}/aws/credentials'"
# exit 99
# else
# export AWS_CONFIG_FILE="${DIP_BASE_DIR}/aws/config"
# export AWS_SHARED_CREDENTIALS_FILE="${DIP_BASE_DIR}/aws/credentials"
# fi
#else
# logerr "ERROR: AWS config directory not found. '${DIP_BASE_DIR}/aws/' is expected to exist and contain 'config' and 'credentials' for AWS access."
# exit 99
#fi
if [[ -z "$DIP_CUR_IP" ]] || [[ -z "$DIP_OLD_IP" ]] || [[ -z "$DIP_RECORD" ]]; then
logerr "ERROR: Agent expects currentip, existingip, and record."
exit 98
fi
_get_host_and_domain() {
local record=$1
hostname=${record%%.*}
domain=${record#*.}
if [[ -n "${agent_update_dns_namecheap_token[$domain]}" ]]; then
token="${agent_update_dns_namecheap_token[$domain]}"
return 0
else
logerr "ERROR: Password for $domain not found in agent configuration."
return 1
fi
}
# Main
_get_host_and_domain "$DIP_RECORD" || exit 97
if valid_ipv4 "$DIP_CUR_IP"; then
log "Updating Namecheap DNS IPv4 Record for ${hostname}.${domain}"
curl "https://dynamicdns.park-your-domain.com/update?host=${hostname}&domain=${domain}&password=${token}&ip=${DIP_CUR_IP}"
fi
if valid_ipv6 "$DIP_CUR_IP"; then
log "Updating Namecheap DNS IPv6 Record for ${hostname}.${domain}"
curl "https://dynamicdns.park-your-domain.com/update?host=${hostname}&domain=${domain}&password=${token}&ip=${DIP_CUR_IP}"
fi

View file

@ -0,0 +1,5 @@
# Namecheap DDNS Passwords
decalre -A agent_update_dns_namecheap_token
#agent_update_dns_namecheap_token[domain.tld]=