update
This commit is contained in:
@@ -6,7 +6,7 @@ DELSITE(){
|
|||||||
-ssl) DEL_SSL=${2};;
|
-ssl) DEL_SSL=${2};;
|
||||||
-list) DELSITES; exit 0;;
|
-list) DELSITES; exit 0;;
|
||||||
-*)
|
-*)
|
||||||
echo "Invalid option: '${1}' requires an argument" 1>&2
|
[ "${1}" != "-h" ] && echo "Invalid option: '${1}' requires an argument" 1>&2
|
||||||
echo
|
echo
|
||||||
echo -e "Usage: ${idsCL[Yellow]}[nodemgmt or nmg] delsite${idsCL[Default]} {"
|
echo -e "Usage: ${idsCL[Yellow]}[nodemgmt or nmg] delsite${idsCL[Default]} {"
|
||||||
width=35
|
width=35
|
||||||
@@ -14,7 +14,7 @@ DELSITE(){
|
|||||||
printf "%-${width}s- %s\n" " -ssl {yes or [no]}" "Delete SSL certs as well"
|
printf "%-${width}s- %s\n" " -ssl {yes or [no]}" "Delete SSL certs as well"
|
||||||
printf "%-${width}s- %s\n" " -list" "List sites (same as running nodemgmt delsites)"
|
printf "%-${width}s- %s\n" " -list" "List sites (same as running nodemgmt delsites)"
|
||||||
echo "}"
|
echo "}"
|
||||||
exit 1;;
|
exit 0;;
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -499,40 +499,48 @@ ADD_LOGROTATE_CRONTAB(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
UPDATE_DYNDNS(){
|
UPDATE_DYNDNS(){
|
||||||
if [ "${1}" == "q" ]; then
|
TESTMODE=0
|
||||||
SENDNOTICE "FOUND OLD DYNDNS SERVER" "IP=$(/sbin/ip -o -4 addr list eth0 |grep 255 | awk '{print $4}' | cut -d/ -f1) - HOSTNAME=$(hostname)"
|
while [ $# -gt 0 ]; do
|
||||||
|
case "$1" in
|
||||||
else
|
-t|-test) TESTMODE=1;;
|
||||||
if [ "${2}" != 'q' ]; then
|
-h | -help | --help)
|
||||||
cw_spc=10
|
echo
|
||||||
echo -e "${idsCL[Yellow]}Checking for DYNDNS update at ${1^} ... ${idsCL[Default]}"
|
echo -e "Usage: ${idsCL[LightYellow]}[nodemgmt or nmg] update-dyndns ${idsCL[Yellow]}{location}${idsCL[Default]} {"
|
||||||
echo
|
width=35
|
||||||
echo -en "${idsCL[LightCyan]}Old IP ${idsCL[White]}: "
|
printf "%-${width}s- %s\n" " {location}" "(site location name to update for)"
|
||||||
fi
|
printf "%-${width}s- %s\n" " -t|-test" "(tests but does not update records)"
|
||||||
|
echo "}"
|
||||||
|
exit 0;;
|
||||||
|
*) LOCATION=${1};;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
if [ "${LOCATION}" == "mainsite" ] || [ "${LOCATION}" == "offsite" ] || [ "${LOCATION}" == "kyle" ]; then
|
||||||
if [ "${NM_DYNUSER}" == "" ] || [ "${NM_DYNPASS}" == "" ]; then
|
if [ "${NM_DYNUSER}" == "" ] || [ "${NM_DYNPASS}" == "" ]; then
|
||||||
echo "Missing DYNDNS username or password (NM_DYNUSER=${NM_DYNUSER}) (NM_DYNPASS=${NM_DYNPASS})"
|
echo "Missing DYNDNS username or password (NM_DYNUSER=${NM_DYNUSER}) (NM_DYNPASS=${NM_DYNPASS})"
|
||||||
SENDNOTICE "${1^^} DYNDNS ERROR" "Missing DYNDNS username or password (NM_DYNUSER=${NM_DYNUSER}) (NM_DYNPASS=${NM_DYNPASS})"
|
SENDNOTICE "${LOCATION^^} DYNDNS ERROR" "Missing DYNDNS username or password (NM_DYNUSER=${NM_DYNUSER}) (NM_DYNPASS=${NM_DYNPASS})" 1
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
cw_spc=10
|
||||||
|
echo -e "${idsCL[Yellow]}Checking for DYNDNS update at ${LOCATION^} ... ${idsCL[Default]}"
|
||||||
|
echo
|
||||||
|
echo -en "${idsCL[LightCyan]}Previous WAN IP ${idsCL[White]}: "
|
||||||
|
|
||||||
if [ "${1}" == "home" ]; then
|
if [ "${LOCATION}" == "mainsite" ]; then
|
||||||
OLDIP=`dig +short sc1.scity.us @wdns.scity.us +time=2`
|
OLDIP=`dig +short sc1.scity.us @wdns.scity.us +time=2`
|
||||||
elif [ "${1}" == "offsite" ]; then
|
elif [ "${LOCATION}" == "offsite" ]; then
|
||||||
OLDIP=`dig +short offsite.scity.us @wdns.scity.us +time=2`
|
OLDIP=`dig +short offsite.scity.us @wdns.scity.us +time=2`
|
||||||
elif [ "${1}" == "kyle" ]; then
|
elif [ "${LOCATION}" == "kyle" ]; then
|
||||||
OLDIP=`dig +short wan.pattonfam.com @wdns.scity.us +time=2`
|
OLDIP=`dig +short wan.pattonfam.com @wdns.scity.us +time=2`
|
||||||
fi
|
fi
|
||||||
if [ "${2}" != 'q' ]; then
|
echo -e "${idsCL[Cyan]}${OLDIP}"
|
||||||
echo -e "${idsCL[Cyan]}${OLDIP}"
|
echo -en "${idsCL[LightCyan]}Current WAN IP ${idsCL[White]}: "
|
||||||
echo -en "${idsCL[LightCyan]}New IP ${idsCL[White]}: "
|
|
||||||
fi
|
|
||||||
NEWIP=`dig +short myip.opendns.com @resolver1.opendns.com +time=2`
|
NEWIP=`dig +short myip.opendns.com @resolver1.opendns.com +time=2`
|
||||||
[ "${2}" != 'q' ] && echo -e "${idsCL[Green]}${NEWIP}"
|
echo -e "${idsCL[Green]}${NEWIP}"
|
||||||
|
|
||||||
if ([ "${OLDIP}" != "" ] && [ "${NEWIP}" != "" ] && [[ "${OLDIP}" != *";"* ]] && [[ "${NEWIP}" != *";"* ]] && [ "${OLDIP}" != "${NEWIP}" ]) || [ "${2}" == "force" ]; then
|
if ([ "${OLDIP}" != "" ] && [ "${NEWIP}" != "" ] && [[ "${OLDIP}" != *";"* ]] && [[ "${NEWIP}" != *";"* ]] && [ "${OLDIP}" != "${NEWIP}" ]) || [ "${2}" == "force" ]; then
|
||||||
[ "${2}" != 'q' ] && echo && echo -en "${idsCL[Green]}${1^} WAN IP has changed, updating records ... "
|
echo && echo -en "${idsCL[Green]}${1^} WAN IP has changed, updating records ... "
|
||||||
if [ "${1}" == "home" ]; 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
|
||||||
/usr/bin/curl -s "https://${NM_DYNUSER}:${NM_DYNPASS}@wdns.scity.us/nic/update?hostname=sc2.scity.us&myip=${NEWIP}" > /dev/null 2>&1
|
/usr/bin/curl -s "https://${NM_DYNUSER}:${NM_DYNPASS}@wdns.scity.us/nic/update?hostname=sc2.scity.us&myip=${NEWIP}" > /dev/null 2>&1
|
||||||
@@ -544,7 +552,7 @@ UPDATE_DYNDNS(){
|
|||||||
#internal dns
|
#internal dns
|
||||||
/usr/bin/curl -s "https://${NM_DYNUSER}:${NM_DYNPASS}@dns.scity.us/nic/update?hostname=sc1.scity.us&myip=${NEWIP}" > /dev/null 2>&1
|
/usr/bin/curl -s "https://${NM_DYNUSER}:${NM_DYNPASS}@dns.scity.us/nic/update?hostname=sc1.scity.us&myip=${NEWIP}" > /dev/null 2>&1
|
||||||
|
|
||||||
elif [ "${1}" == "offsite" ]; then
|
elif [ "${LOCATION}" == "offsite" ]; then
|
||||||
#external dns
|
#external dns
|
||||||
/usr/bin/curl -s "https://${NM_DYNUSER}:${NM_DYNPASS}@wdns.scity.us/nic/update?hostname=offsite.scity.us&myip=${NEWIP}" > /dev/null 2>&1
|
/usr/bin/curl -s "https://${NM_DYNUSER}:${NM_DYNPASS}@wdns.scity.us/nic/update?hostname=offsite.scity.us&myip=${NEWIP}" > /dev/null 2>&1
|
||||||
/usr/bin/curl -s "https://${NM_DYNUSER}:${NM_DYNPASS}@wdns.scity.us/nic/update?hostname=backup.scity.us&myip=${NEWIP}" > /dev/null 2>&1
|
/usr/bin/curl -s "https://${NM_DYNUSER}:${NM_DYNPASS}@wdns.scity.us/nic/update?hostname=backup.scity.us&myip=${NEWIP}" > /dev/null 2>&1
|
||||||
@@ -552,30 +560,27 @@ UPDATE_DYNDNS(){
|
|||||||
/usr/bin/curl -s "https://${NM_DYNUSER}:${NM_DYNPASS}@dns.scity.us/nic/update?hostname=offsite.scity.us&myip=${NEWIP}" > /dev/null 2>&1
|
/usr/bin/curl -s "https://${NM_DYNUSER}:${NM_DYNPASS}@dns.scity.us/nic/update?hostname=offsite.scity.us&myip=${NEWIP}" > /dev/null 2>&1
|
||||||
/usr/bin/curl -s "https://${NM_DYNUSER}:${NM_DYNPASS}@dns.scity.us/nic/update?hostname=backup.scity.us&myip=${NEWIP}" > /dev/null 2>&1
|
/usr/bin/curl -s "https://${NM_DYNUSER}:${NM_DYNPASS}@dns.scity.us/nic/update?hostname=backup.scity.us&myip=${NEWIP}" > /dev/null 2>&1
|
||||||
|
|
||||||
elif [ "${1}" == "kyle" ]; then
|
elif [ "${LOCATION}" == "kyle" ]; then
|
||||||
/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 "${1^^} DYNDNS Updated" "Updated ${1^} WAN IP from '${OLDIP}' to '${NEWIP}'"
|
SENDNOTICE "${LOCATION^^} DYNDNS Updated" "Updated ${1^} WAN IP from '${OLDIP}' to '${NEWIP}'"
|
||||||
[ "${2}" != 'q' ] && echo -e "${idsCL[Green]}done${idsCL[Default]}"
|
echo -e "${idsCL[Green]}done${idsCL[Default]}"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
elif [[ "${NEWIP}" == *";"* ]] || [[ "${OLDIP}" == *";"* ]]; then
|
elif [[ "${NEWIP}" == *";"* ]] || [[ "${OLDIP}" == *";"* ]]; then
|
||||||
[ "${2}" != 'q' ] && echo -e "${idsCL[Red]}Could not do dns lookup${idsCL[Default]}"
|
echo -e "${idsCL[Red]}Could not do dns lookup${idsCL[Default]}"
|
||||||
# SENDNOTICE "${1^^} DYNDNS Could not Update" "Connection error, could reach any servers"
|
# SENDNOTICE "${1^^} DYNDNS Could not Update" "Connection error, could reach any servers"
|
||||||
elif [ "${OLDIP}" == "" ]; then
|
elif [ "${OLDIP}" == "" ]; then
|
||||||
[ "${2}" != 'q' ] && echo -e "${idsCL[Red]}Could not get OLD IP${idsCL[Default]}"
|
echo -e "${idsCL[Red]}Could not get PREVIOUS WAN IP${idsCL[Default]}"
|
||||||
elif [ "${NEWIP}" == "" ]; then
|
elif [ "${NEWIP}" == "" ]; then
|
||||||
[ "${2}" != 'q' ] && echo -e "${idsCL[Red]}Could not get NEW IP${idsCL[Default]}"
|
echo -e "${idsCL[Red]}Could not get CURRENT WAN IP${idsCL[Default]}"
|
||||||
else
|
else
|
||||||
[ "${2}" != 'q' ] && echo -e "${idsCL[Green]}${1^^} WAN IP has not changed${idsCL[Default]}"
|
echo -e "${idsCL[Green]}'${LOCATION^^}' WAN IP has not changed${idsCL[Default]}"
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "${2}" != 'q' ]; then
|
|
||||||
echo
|
|
||||||
# read -n 1 -s -p "Press any key to continue"
|
|
||||||
# echo
|
|
||||||
fi
|
fi
|
||||||
|
echo
|
||||||
|
else
|
||||||
|
echo -e "\n${idsCL[Red]}DYNDNS location '${LOCATION}' not recognized"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user