#!/usr/bin/env bash # https://www.dynu.com/DynamicDNS/IPUpdateClient/cURL #### OPTIONS set -o errexit -o pipefail #### DEFINITIONS PROG=$(basename "${0}") DDNS_USERNAME="${DDNS_USERNAME:-}" DDNS_PASSWORD="${DDNS_PASSWORD:-}" DDNS_HOSTNAME="${DDNS_HOSTNAME:-}" DDNS_ALIAS="${DDNS_ALIAS:-}" IPV4="${DDNS_IPV4:-auto}" IPV6="${DDNS_IPV6:-no}" #### FUNCTIONS ## Function to throw an error function throw_error() { local error_input="${1}" printf "[ERROR]: %s\n" "${error_input}" >&2 exit 1 } function is_installed(){ local input="${1}" if ! command -v "${input}" >/dev/null 2>&1; then throw_error "Cannot find '${input}' in PATH. Please make sure '${input}' is installed and is in your PATH" fi } #### MAIN is_installed "curl" curl \ --location \ --user "${DDNS_USERNAME}:${DDNS_PASSWORD}" \ "https://api.dynu.com/nic/update?hostname=${DDNS_HOSTNAME}&myip=${IPV4}&myipv6=${IPV6}"