Small bugfixes an new compatibility with FreeBSD10

- Changed default IP check site to ifconfig.me
- Added a switch to use _drill_ instead of _nslookup_ because FreeBSD
10 switched from _bind_ to _unbound_
- Renamed _$HOSTNAME_ to _$DOMAIN_ to work around potential conflicts
with _$HOSTNAME_ that's set by the host itself
This commit is contained in:
2014-02-02 10:49:00 +01:00
parent d85dde5f17
commit 8fc04ac46b
3 changed files with 26 additions and 7 deletions

View File

@ -24,14 +24,16 @@
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# from which site should we get your wan ip?
IP_CHECK_SITE=http://checkip.dyndns.org
source $(dirname $0)/nsupdate.config
LOG=$0.log
NSLOOKUP=$(nslookup -sil $HOSTNAME - ns.inwx.de | tail -2 | head -1 | cut -d' ' -f2)
if [[ "$USE_DRILL" == "YES" ]]; then
NSLOOKUP=$(drill $DOMAIN @ns.inwx.de | head -7 | tail -1 | awk '{print $5}')
else
NSLOOKUP=$(nslookup -sil $DOMAIN - ns.inwx.de | tail -2 | head -1 | cut -d' ' -f2)
fi
WAN_IP=`curl -s ${IP_CHECK_SITE}| grep -Eo '\<[[:digit:]]{1,3}(\.[[:digit:]]{1,3}){3}\>'`
API_XML="<?xml version=\"1.0\"?>
@ -73,7 +75,7 @@ API_XML="<?xml version=\"1.0\"?>
if [ ! "$NSLOOKUP" == "$WAN_IP" ]; then
curl -silent -v -XPOST -H"Content-Type: application/xml" -d "$API_XML" https://api.domrobot.com/xmlrpc/
echo "$(date) - $HOSTNAME updated. Old IP: "$NSLOOKUP "New IP: "$WAN_IP >> $LOG
echo "$(date) - $DOMAIN updated. Old IP: "$NSLOOKUP "New IP: "$WAN_IP >> $LOG
else
echo "$(date) - No update needed for $HOSTNAME. Current IP: "$NSLOOKUP >> $LOG
echo "$(date) - No update needed for $DOMAIN. Current IP: "$NSLOOKUP >> $LOG
fi