Use correct mechanism
This commit is contained in:
parent
8c82fa5b70
commit
dc5c6551c4
1 changed files with 22 additions and 10 deletions
|
@ -100,6 +100,19 @@ echo "Checking ${hostname}"
|
|||
if [ "${DYNV6_IPV6_ENABLED}" = "true" ]; then
|
||||
echo "Testing IPv6";
|
||||
ipv6Address=$(LC_ALL=C /usr/bin/ip -c=never -6 -o a s dev ${DYNV6_IPV6_INTERFACE} | grep --color=never -Po '(?<=inet6 )(2.*?)(?=\/64 scope global dynamic mngtmpaddr)')
|
||||
|
||||
ipv6AddressLocalFile="/tmp/dynv6_ip6";
|
||||
|
||||
if [ ! -f "${ipv6AddressLocalFile}" ]; then
|
||||
touch "${ipv6AddressLocalFile}";
|
||||
fi
|
||||
|
||||
if grep --color=never -Fxq ${ipv6Address} "${ipv6AddressLocalFile}"; then
|
||||
echo "IPv6 is still ${ipv6Address}";
|
||||
else
|
||||
echo "IPv6 changed"
|
||||
echo "${ipv6Address}" > "${ipv6AddressLocalFile}";
|
||||
|
||||
ipv6Res=$(curl -s -v "https://ipv6.dynv6.com/api/update?hostname=${hostname}&ipv6=${ipv6Address}&token=${token}")
|
||||
ipv6Changed=true;
|
||||
|
||||
|
@ -107,14 +120,13 @@ if [ "${DYNV6_IPV6_ENABLED}" = "true" ]; then
|
|||
ipv6Changed=false;
|
||||
fi
|
||||
if [ "${ipv6Changed}" = "true" ]; then
|
||||
echo "IPv6 changed"
|
||||
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue