Merge pull request #5 from Brinkyeti/master
added support for mx records and some sort of silent ouput/logs
This commit is contained in:
commit
ba24522d07
@ -6,6 +6,7 @@ IP_CHECK_SITE="https://ip.dblx.io"
|
|||||||
# use drill instead of nslookup for hostname lookup
|
# use drill instead of nslookup for hostname lookup
|
||||||
USE_DRILL="YES"
|
USE_DRILL="YES"
|
||||||
IPV6="NO"
|
IPV6="NO"
|
||||||
|
MX="NO"
|
||||||
|
|
||||||
# Login credentials for the inwx admin interface
|
# Login credentials for the inwx admin interface
|
||||||
INWX_USER="USERNAME"
|
INWX_USER="USERNAME"
|
||||||
|
33
nsupdate.sh
33
nsupdate.sh
@ -1,4 +1,4 @@
|
|||||||
#!/usr/local/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Update a nameserver entry at inwx with the current WAN IP (DynDNS)
|
# Update a nameserver entry at inwx with the current WAN IP (DynDNS)
|
||||||
|
|
||||||
@ -39,17 +39,24 @@ fi
|
|||||||
##################
|
##################
|
||||||
|
|
||||||
LOG=$0.log
|
LOG=$0.log
|
||||||
|
SILENT=NO
|
||||||
# Loop through configs
|
# Loop through configs
|
||||||
for f in $(dirname $0)/nsupdate.d/*.config
|
for f in $(dirname $0)/nsupdate.d/*.config
|
||||||
do
|
do
|
||||||
echo "Starting nameserver update with config file $f"
|
if [ "$SILENT" == "NO" ]; then
|
||||||
|
echo "Starting nameserver update with config file $f"
|
||||||
|
fi
|
||||||
## Set record type to IPv4
|
## Set record type to IPv4
|
||||||
TYPE=A
|
TYPE=A
|
||||||
CONNECTION_TYPE=4
|
CONNECTION_TYPE=4
|
||||||
|
|
||||||
source $f
|
source $f
|
||||||
|
|
||||||
|
## Set record type to MX
|
||||||
|
if [[ "$MX" == "YES" ]]; then
|
||||||
|
TYPE=MX
|
||||||
|
fi
|
||||||
|
|
||||||
## Set record type to IPv6
|
## Set record type to IPv6
|
||||||
if [[ "$IPV6" == "YES" ]]; then
|
if [[ "$IPV6" == "YES" ]]; then
|
||||||
TYPE=AAAA
|
TYPE=AAAA
|
||||||
@ -57,14 +64,25 @@ do
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$USE_DRILL" == "YES" ]]; then
|
if [[ "$USE_DRILL" == "YES" ]]; then
|
||||||
NSLOOKUP=$(drill $DOMAIN @ns.inwx.de $TYPE | head -7 | tail -1 | awk '{print $5}')
|
if [[ "$TYPE" == "MX" ]]; then
|
||||||
|
echo looking up MX records with drill currently not supported!
|
||||||
|
exit 1;
|
||||||
|
else
|
||||||
|
NSLOOKUP=$(drill $DOMAIN @ns.inwx.de $TYPE | head -7 | tail -1 | awk '{print $5}')
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
NSLOOKUP=$(nslookup -sil -type=$TYPE $DOMAIN - ns.inwx.de | tail -2 | head -1 | cut -d' ' -f2)
|
if [[ "$TYPE" == "MX" ]]; then
|
||||||
|
PART_NSLOOKUP=$(nslookup -sil -type=$TYPE $DOMAIN - ns.inwx.de | tail -2 | head -1 | cut -d' ' -f5)
|
||||||
|
NSLOOKUP=${PART_NSLOOKUP%"."}
|
||||||
|
else
|
||||||
|
NSLOOKUP=$(nslookup -sil -type=$TYPE $DOMAIN - ns.inwx.de | tail -2 | head -1 | cut -d' ' -f2)
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# WAN_IP=`curl -s -$CONNECTION_TYPE ${IP_CHECK_SITE}| grep -Eo '\<[[:digit:]]{1,3}(\.[[:digit:]]{1,3}){3}\>'`
|
# WAN_IP=`curl -s -$CONNECTION_TYPE ${IP_CHECK_SITE}| grep -Eo '\<[[:digit:]]{1,3}(\.[[:digit:]]{1,3}){3}\>'`
|
||||||
WAN_IP=`curl -s -$CONNECTION_TYPE ${IP_CHECK_SITE}`
|
WAN_IP=`curl -s -$CONNECTION_TYPE ${IP_CHECK_SITE}`
|
||||||
|
|
||||||
|
|
||||||
API_XML="<?xml version=\"1.0\"?>
|
API_XML="<?xml version=\"1.0\"?>
|
||||||
<methodCall>
|
<methodCall>
|
||||||
<methodName>nameserver.updateRecord</methodName>
|
<methodName>nameserver.updateRecord</methodName>
|
||||||
@ -101,16 +119,17 @@ do
|
|||||||
</param>
|
</param>
|
||||||
</params>
|
</params>
|
||||||
</methodCall>"
|
</methodCall>"
|
||||||
|
|
||||||
if [ ! "$NSLOOKUP" == "$WAN_IP" ]; then
|
if [ ! "$NSLOOKUP" == "$WAN_IP" ]; then
|
||||||
curl -silent -v -XPOST -H"Content-Type: application/xml" -d "$API_XML" https://api.domrobot.com/xmlrpc/
|
curl -silent -v -XPOST -H"Content-Type: application/xml" -d "$API_XML" https://api.domrobot.com/xmlrpc/
|
||||||
echo "$(date) - $DOMAIN updated. Old IP: "$NSLOOKUP "New IP: "$WAN_IP >> $LOG
|
echo "$(date) - $DOMAIN updated. Old IP: "$NSLOOKUP "New IP: "$WAN_IP >> $LOG
|
||||||
else
|
elif [ "$SILENT" == "NO" ]; then
|
||||||
echo "$(date) - No update needed for $DOMAIN. Current IP: "$NSLOOKUP >> $LOG
|
echo "$(date) - No update needed for $DOMAIN. Current IP: "$NSLOOKUP >> $LOG
|
||||||
fi
|
fi
|
||||||
|
|
||||||
unset DOMAIN
|
unset DOMAIN
|
||||||
unset IPV6
|
unset IPV6
|
||||||
|
unset MX
|
||||||
unset WAN_IP
|
unset WAN_IP
|
||||||
unset NSLOOKUP
|
unset NSLOOKUP
|
||||||
unset INWX_PASS
|
unset INWX_PASS
|
||||||
|
Loading…
x
Reference in New Issue
Block a user