Update nodemgmt-scripts.sh

This commit is contained in:
2025-05-26 22:33:17 -05:00
parent e8079ac6aa
commit 7d93db8d7c

View File

@@ -497,19 +497,20 @@ UPDATE_DYNDNS(){
OLDIP=`dig +short ${DYNDNS_HOSTS[0]} @${PDNS_SERVER} +time=2`;
echo -e "${idsCL[Cyan]}${OLDIP}"
echo -en "${idsCL[White]}Current WAN IP : ";
NEWIP="$(dig +short myip.opendns.com @resolver1.opendns.com)" >/dev/null 2>&1
NEWIP="$(dig +short myip.opendns.com @resolver1.opendns.com +time=2)" >/dev/null 2>&1
if [ "${NEWIP}" == "" ]; then
NEWIP="$(wget -qO- https://ipinfo.io/ip ; echo)" >/dev/null 2>&1
if [ "${NEWIP}" == "" ]; then
NEWIP="$(wget -qO- https://ipecho.net/plain ; echo)" >/dev/null 2>&1
[ "${NEWIP}" == "" ] && NEWIP="WAN IP could not be found"
else
NEWIP="WAN IP could not be found"
fi
fi
# NEWIP=`dig +short myip.opendns.com @resolver1.opendns.com +time=2`;
echo -e "${idsCL[LightGreen]}${NEWIP}"
echo
if ([ "${OLDIP}" != "" ] && [ "${NEWIP}" != "" ] && [[ "${OLDIP}" != *";"* ]] && [[ "${NEWIP}" != *";"* ]]) && ([ "${OLDIP}" != "${NEWIP}" ] || [ ${FORCE} -eq 1 ]); then
if ([ "${OLDIP}" != "" ] && [ "${NEWIP}" != "" ] && [[ "${OLDIP}" != *";"* ]] && [[ "${NEWIP}" != *";"* ]] && [[ "${NEWIP}" != "WAN"* ]]) && ([ "${OLDIP}" != "${NEWIP}" ] || [ ${FORCE} -eq 1 ]); then
if [ ${TESTMODE} -eq 1 ]; then
echo -e "${idsCL[Green]}'${idsCL[LightCyan]}${LOCATION^^}${idsCL[Green]}' WAN IP has changed: ${idsCL[Yellow]}testmode active and will not update records${idsCL[Default]}"
else
@@ -521,9 +522,9 @@ UPDATE_DYNDNS(){
fi
if [ "${NM_PDNS_USER}" != "" ] && [ "${NM_PDNS_PASS}" != "" ]; then
if [ "$(curl -m 3 -sL "https://${NM_PDNS_USER}df:${NM_PDNS_PASS}@${PDNS_SERVER}/domain/${domain}" | grep "HTTP 403 Error")" == "" ]; then
# for host in ${DYNDNS_HOSTS[@]}; do
# /usr/bin/curl -s "https://${NM_PDNS_USER}:${NM_PDNS_PASS}@${PDNS_SERVER}/nic/update?hostname=${host}&myip=${NEWIP}" > /dev/null 2>&1
# done
for host in ${DYNDNS_HOSTS[@]}; do
/usr/bin/curl -s "https://${NM_PDNS_USER}:${NM_PDNS_PASS}@${PDNS_SERVER}/nic/update?hostname=${host}&myip=${NEWIP}" > /dev/null 2>&1
done
if [ "${NM_PDNS_USER}" == "systems" ]; then
[ "${LOCATION,,}" == "mainsite" ] && /usr/bin/curl -s "https://${NM_PDNS_USER}:${NM_PDNS_PASS}@${NM_PDNS_LANDNS}/nic/update?hostname=sc1.scity.us&myip=${NEWIP}" > /dev/null 2>&1
[ "${LOCATION,,}" == "offsite" ] && /usr/bin/curl -s "https://${NM_PDNS_USER}:${NM_PDNS_PASS}@${NM_PDNS_LANDNS}/nic/update?hostname=wan.offsite.scity.us&myip=${NEWIP}" > /dev/null 2>&1