Update nodemgmt-scripts.sh
This commit is contained in:
@@ -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(){
|
||||
|
||||
Reference in New Issue
Block a user