From 095f0678c0a98b108ae1bfb12a617034287a974c Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Tue, 14 Nov 2023 15:38:46 -0600 Subject: [PATCH] Update nodemgmt-scripts.sh --- nodemgmt-scripts.sh | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/nodemgmt-scripts.sh b/nodemgmt-scripts.sh index cc87b1e2..c1d8fe8f 100755 --- a/nodemgmt-scripts.sh +++ b/nodemgmt-scripts.sh @@ -499,15 +499,17 @@ ADD_LOGROTATE_CRONTAB(){ } UPDATE_DYNDNS(){ - TESTMODE=0 + TESTMODE=0; FORCE=0; while [ $# -gt 0 ]; do case "$1" in - -t|-test) TESTMODE=1;; + -f|-force) FORCE=1;; + -t) TESTMODE=1;; -h | -help | --help) echo echo -e "Usage: ${idsCL[LightYellow]}[nodemgmt or nmg] update-dyndns ${idsCL[Yellow]}{location}${idsCL[Default]} {" width=35 printf "%-${width}s- %s\n" " {location}" "(site location name to update for)" + printf "%-${width}s- %s\n" " -f|-force" "(will force a record update without IP changing)" printf "%-${width}s- %s\n" " -t|-test" "(tests but does not update records)" echo "}" exit 0;; @@ -537,9 +539,10 @@ UPDATE_DYNDNS(){ echo -en "${idsCL[LightCyan]}Current WAN IP ${idsCL[White]}: " NEWIP=`dig +short myip.opendns.com @resolver1.opendns.com +time=2` echo -e "${idsCL[Green]}${NEWIP}" - - if ([ "${OLDIP}" != "" ] && [ "${NEWIP}" != "" ] && [[ "${OLDIP}" != *";"* ]] && [[ "${NEWIP}" != *";"* ]] && [ "${OLDIP}" != "${NEWIP}" ]) || [ "${2}" == "force" ]; then - echo && echo -en "${idsCL[Green]}${1^} WAN IP has changed, updating records ... " + echo + + if ([ "${OLDIP}" != "" ] && [ "${NEWIP}" != "" ] && [[ "${OLDIP}" != *";"* ]] && [[ "${NEWIP}" != *";"* ]] && [ "${OLDIP}" != "${NEWIP}" ]) || [ ${FORCE} -eq 1 ]; then + echo -en "${idsCL[Green]}${LOCATION^} WAN IP has changed, updating records ... " if [ "${LOCATION}" == "mainsite" ]; then #external dns /usr/bin/curl -s "https://${NM_DYNUSER}:${NM_DYNPASS}@wdns.scity.us/nic/update?hostname=sc1.scity.us&myip=${NEWIP}" > /dev/null 2>&1 @@ -564,24 +567,23 @@ UPDATE_DYNDNS(){ /usr/bin/curl -s "https://${NM_DYNUSER}:${NM_DYNPASS}@wdns.scity.us/nic/update?hostname=wan.pattonfam.com&myip=${NEWIP}" > /dev/null 2>&1 fi - SENDNOTICE "${LOCATION^^} DYNDNS Updated" "Updated ${1^} WAN IP from '${OLDIP}' to '${NEWIP}'" - echo -e "${idsCL[Green]}done${idsCL[Default]}" - echo + SENDNOTICE "${LOCATION^^} DYNDNS Updated" "Updated ${LOCATION^} WAN IP from '${OLDIP}' to '${NEWIP}'" + echo -e "${idsCL[Green]}Done${idsCL[Default]}" elif [[ "${NEWIP}" == *";"* ]] || [[ "${OLDIP}" == *";"* ]]; then - echo -e "${idsCL[Red]}Could not do dns lookup${idsCL[Default]}" - # SENDNOTICE "${1^^} DYNDNS Could not Update" "Connection error, could reach any servers" + echo -e "${idsCL[Red]}Could not perform DNS Lookups${idsCL[Default]}" + # SENDNOTICE "${LOCATION^^} DYNDNS Could not Update" "Connection error, could reach any servers" elif [ "${OLDIP}" == "" ]; then - echo -e "${idsCL[Red]}Could not get PREVIOUS WAN IP${idsCL[Default]}" + echo -e "${idsCL[Red]}Could not get Previous WAN IP${idsCL[Default]}" elif [ "${NEWIP}" == "" ]; then - echo -e "${idsCL[Red]}Could not get CURRENT WAN IP${idsCL[Default]}" + echo -e "${idsCL[Red]}Could not get Current WAN IP${idsCL[Default]}" else - echo -e "${idsCL[Green]}'${LOCATION^^}' WAN IP has not changed${idsCL[Default]}" + echo -e "${idsCL[Green]}'${idsCL[Green]}${LOCATION^^}${idsCL[Green]}' WAN IP has not changed${idsCL[Default]}" fi - echo else echo -e "\n${idsCL[Red]}DYNDNS location '${LOCATION}' not recognized" fi + echo } BACKUP_OFFSITEPFSENSE(){