Update nodemgmt-scripts.sh

This commit is contained in:
2023-11-14 15:38:46 -06:00
parent 0da1f7ccee
commit 095f0678c0

View File

@@ -499,15 +499,17 @@ ADD_LOGROTATE_CRONTAB(){
} }
UPDATE_DYNDNS(){ UPDATE_DYNDNS(){
TESTMODE=0 TESTMODE=0; FORCE=0;
while [ $# -gt 0 ]; do while [ $# -gt 0 ]; do
case "$1" in case "$1" in
-t|-test) TESTMODE=1;; -f|-force) FORCE=1;;
-t) TESTMODE=1;;
-h | -help | --help) -h | -help | --help)
echo echo
echo -e "Usage: ${idsCL[LightYellow]}[nodemgmt or nmg] update-dyndns ${idsCL[Yellow]}{location}${idsCL[Default]} {" echo -e "Usage: ${idsCL[LightYellow]}[nodemgmt or nmg] update-dyndns ${idsCL[Yellow]}{location}${idsCL[Default]} {"
width=35 width=35
printf "%-${width}s- %s\n" " {location}" "(site location name to update for)" 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)" printf "%-${width}s- %s\n" " -t|-test" "(tests but does not update records)"
echo "}" echo "}"
exit 0;; exit 0;;
@@ -537,9 +539,10 @@ UPDATE_DYNDNS(){
echo -en "${idsCL[LightCyan]}Current WAN IP ${idsCL[White]}: " echo -en "${idsCL[LightCyan]}Current WAN IP ${idsCL[White]}: "
NEWIP=`dig +short myip.opendns.com @resolver1.opendns.com +time=2` NEWIP=`dig +short myip.opendns.com @resolver1.opendns.com +time=2`
echo -e "${idsCL[Green]}${NEWIP}" echo -e "${idsCL[Green]}${NEWIP}"
echo
if ([ "${OLDIP}" != "" ] && [ "${NEWIP}" != "" ] && [[ "${OLDIP}" != *";"* ]] && [[ "${NEWIP}" != *";"* ]] && [ "${OLDIP}" != "${NEWIP}" ]) || [ "${2}" == "force" ]; then
echo && echo -en "${idsCL[Green]}${1^} WAN IP has changed, updating records ... " 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 if [ "${LOCATION}" == "mainsite" ]; then
#external dns #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 /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 /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 fi
SENDNOTICE "${LOCATION^^} DYNDNS Updated" "Updated ${1^} WAN IP from '${OLDIP}' to '${NEWIP}'" SENDNOTICE "${LOCATION^^} DYNDNS Updated" "Updated ${LOCATION^} WAN IP from '${OLDIP}' to '${NEWIP}'"
echo -e "${idsCL[Green]}done${idsCL[Default]}" echo -e "${idsCL[Green]}Done${idsCL[Default]}"
echo
elif [[ "${NEWIP}" == *";"* ]] || [[ "${OLDIP}" == *";"* ]]; then elif [[ "${NEWIP}" == *";"* ]] || [[ "${OLDIP}" == *";"* ]]; then
echo -e "${idsCL[Red]}Could not do dns lookup${idsCL[Default]}" echo -e "${idsCL[Red]}Could not perform DNS Lookups${idsCL[Default]}"
# SENDNOTICE "${1^^} DYNDNS Could not Update" "Connection error, could reach any servers" # SENDNOTICE "${LOCATION^^} DYNDNS Could not Update" "Connection error, could reach any servers"
elif [ "${OLDIP}" == "" ]; then 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 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 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 fi
echo
else else
echo -e "\n${idsCL[Red]}DYNDNS location '${LOCATION}' not recognized" echo -e "\n${idsCL[Red]}DYNDNS location '${LOCATION}' not recognized"
fi fi
echo
} }
BACKUP_OFFSITEPFSENSE(){ BACKUP_OFFSITEPFSENSE(){