update
This commit is contained in:
@@ -408,10 +408,11 @@ ADD_LOGROTATE_CRONTAB(){
|
||||
}
|
||||
|
||||
UPDATE_DYNDNS(){
|
||||
[ "${NM_DYNHOST}" != "" ] && PDNS_SERVER=${NM_DYNHOST} || PDNS_SERVER=${NM_WANDNS}
|
||||
[ "${NM_PDNS_HOST}" != "" ] && PDNS_SERVER=${NM_PDNS_HOST} || PDNS_SERVER=${NM_PDNS_WANDNS}
|
||||
TESTMODE=0; FORCE=0;
|
||||
while [ $# -gt 0 ]; do
|
||||
case "${1}" in
|
||||
-s|-site) FORCE=1;;
|
||||
-f|-force) FORCE=1;;
|
||||
-t|-test) TESTMODE=1;;
|
||||
-h | -help | --help)
|
||||
@@ -419,6 +420,7 @@ UPDATE_DYNDNS(){
|
||||
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" " -s|-site" "(configured site to run for [NM_DYNDNS_SITES variable])"
|
||||
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 "}"
|
||||
@@ -427,9 +429,9 @@ UPDATE_DYNDNS(){
|
||||
esac
|
||||
shift
|
||||
done
|
||||
if [ "${NM_DYNDNS_LOC[${LOCATION,,}]}" != "" ]; then
|
||||
if [ "${NM_DYNDNS_SITES[${LOCATION,,}]}" != "" ]; then
|
||||
arr DYNDNS_HOSTS
|
||||
IFS=,; hosts=(${NM_DYNDNS_LOC[${LOCATION,,}]}); unset IFS
|
||||
IFS=,; hosts=(${NM_DYNDNS_SITES[${LOCATION,,}]}); unset IFS
|
||||
for host in "${hosts[@]}"; do
|
||||
arr_insert DYNDNS_HOSTS ${host}
|
||||
done
|
||||
@@ -452,22 +454,24 @@ UPDATE_DYNDNS(){
|
||||
SENDNOTICE "${LOCATION^^} WAN IP Changed" "Updated '${LOCATION^}' WAN IP from '${OLDIP}' to '${NEWIP}'"
|
||||
echo -en "${idsCL[Green]}'${idsCL[LightCyan]}${LOCATION^^}${idsCL[Green]}' WAN IP has changed, updating all pre-defined 'A' records ... "
|
||||
fi
|
||||
if [ "${NM_DYNUSER}" != "" ] && [ "${NM_DYNPASS}" != "" ]; then
|
||||
if [ "$(curl -m 3 -sL "https://${NM_DYNUSER}df:${NM_DYNPASS}@${PDNS_SERVER}/domain/${domain}" | grep "HTTP 403 Error")" == "" ]; then
|
||||
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_DYNUSER}:${NM_DYNPASS}@${PDNS_SERVER}/nic/update?hostname=${host}&myip=${NEWIP}" > /dev/null 2>&1
|
||||
/usr/bin/curl -s "https://${NM_PDNS_USER}:${NM_PDNS_PASS}@${PDNS_SERVER}/nic/update?hostname=${host}&myip=${NEWIP}" > /dev/null 2>&1
|
||||
done
|
||||
[ "${LOCATION,,}" == "mainsite" ] && /usr/bin/curl -s "https://${NM_DYNUSER}:${NM_DYNPASS}@${NM_LANDNS}/nic/update?hostname=sc1.scity.us&myip=${NEWIP}" > /dev/null 2>&1
|
||||
[ "${LOCATION,,}" == "offsite" ] && /usr/bin/curl -s "https://${NM_DYNUSER}:${NM_DYNPASS}@${NM_LANDNS}/nic/update?hostname=wan.offsite.scity.us&myip=${NEWIP}" > /dev/null 2>&1
|
||||
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
|
||||
fi
|
||||
echo -e "${idsCL[Green]}Done${idsCL[Default]}"
|
||||
else
|
||||
echo -e "\n\n${idsCL[LightRed]}INVALID DYNDNS username and/or password (NM_DYNUSER=${NM_DYNUSER}) (NM_DYNPASS=${NM_DYNPASS})\n"
|
||||
# SENDNOTICE "${LOCATION^^} DYNDNS ERROR" "INVALID DYNDNS username or password (NM_DYNUSER=${NM_DYNUSER}) (NM_DYNPASS=${NM_DYNPASS})" 1
|
||||
echo -e "\n\n${idsCL[LightRed]}INVALID DYNDNS username and/or password (NM_PDNS_USER=${NM_PDNS_USER}) (NM_PDNS_PASS=${NM_PDNS_PASS})\n"
|
||||
# SENDNOTICE "${LOCATION^^} DYNDNS ERROR" "INVALID DYNDNS username or password (NM_PDNS_USER=${NM_PDNS_USER}) (NM_PDNS_PASS=${NM_PDNS_PASS})" 1
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo -e "\n\n${idsCL[LightYellow]}Missing DYNDNS username and/or password (NM_DYNUSER=${NM_DYNUSER}) (NM_DYNPASS=${NM_DYNPASS})\n"
|
||||
# SENDNOTICE "${LOCATION^^} DYNDNS ERROR" "MISSING DYNDNS username or password (NM_DYNUSER=${NM_DYNUSER}) (NM_DYNPASS=${NM_DYNPASS})" 1
|
||||
echo -e "\n\n${idsCL[LightYellow]}Missing DYNDNS username and/or password (NM_PDNS_USER=${NM_PDNS_USER}) (NM_PDNS_PASS=${NM_PDNS_PASS})\n"
|
||||
# SENDNOTICE "${LOCATION^^} DYNDNS ERROR" "MISSING DYNDNS username or password (NM_PDNS_USER=${NM_PDNS_USER}) (NM_PDNS_PASS=${NM_PDNS_PASS})" 1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -485,7 +489,7 @@ UPDATE_DYNDNS(){
|
||||
fi
|
||||
if [ ${TESTMODE} -eq 1 ]; then
|
||||
echo -en "\nDYNDNS Credential Test: "
|
||||
if [ "$(curl -m 3 -sL "https://${NM_DYNUSER}df:${NM_DYNPASS}@${PDNS_SERVER}/domain/${domain}" | grep "HTTP 403 Error")" == "" ]; then
|
||||
if [ "$(curl -m 3 -sL "https://${NM_PDNS_USER}df:${NM_PDNS_PASS}@${PDNS_SERVER}/domain/${domain}" | grep "HTTP 403 Error")" == "" ]; then
|
||||
echo -e "${idsCL[Green]}Pass${idsCL[Default]}"
|
||||
else
|
||||
echo -e "${idsCL[LightRed]}Fail${idsCL[Default]}"
|
||||
|
||||
Reference in New Issue
Block a user