#!/usr/bin/env bash set -e; usage() { USAGE=$(cat < "${ipv6AddressLocalFile}"; ipv6Res=$(curl -s -v "https://ipv6.dynv6.com/api/update?hostname=${hostname}&ipv6=${ipv6Address}&token=${token}") ipv6Changed=true; if [ "${ipv6Res}" = "addresses unchanged" ]; then ipv6Changed=false; fi if [ "${ipv6Changed}" = "true" ]; then if [ "${DYNV6_MAIL_ENABLED}" = "true" ]; then HOSTMACHINE=$(hostname) echo -e "IPv6 for ${hostname} on host ${HOSTMACHINE} changed to ${ipv6Address}" | mailx -s "[dynv6 IPv6 ${HOSTMACHINE}] IPv6 changed for ${hostname}" "${DYNV6_MAIL_ADDRESS}" fi fi fi fi # ipv4 if [ "${DYNV6_IPV4_ENABLED}" = "true" ]; then echo "Testing IPv4"; ipv4Address=$(curl -s "https://api.ipify.org/?format=text") ipv4Res=$(curl -fsS "https://ipv4.dynv6.com/api/update?hostname=${hostname}&ipv4=${ipv4Address}&token=${token}") ipv4Changed=true; if [ "$ipv4Res" = "addresses unchanged" ]; then ipv4Changed=false; fi if [ "${ipv4Changed}" = "true" ]; then echo "IPv4 changed" if [ "${DYNV6_MAIL_ENABLED}" = "true" ]; then HOSTMACHINE=$(hostname) echo -e "IPv4 for ${hostname} on host ${HOSTMACHINE} changed to ${ipv4Address}" | mailx -s "[dynv6 IPv4 ${HOSTMACHINE}] IPv4 changed for ${hostname}" "${DYNV6_MAIL_ADDRESS}" fi fi fi