#!/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 # Main if valid_ipv4 "$DIP_CUR_IP"; then log "Updating Route53 DNS IPv4 Record" /usr/local/bin/cli53 rc --replace "$agent_update_dns_r53_id" "${DIP_RECORD}. 300 A ${DIP_CUR_IP}" fi if valid_ipv6 "$DIP_CUR_IP"; then log "Updating Route53 DNS IPv6 Record" /usr/local/bin/cli53 rc --replace "$agent_update_dns_r53_id" "${DIP_RECORD}. 300 AAAA ${DIP_CUR_IP}" fi