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:
parent
d85dde5f17
commit
8fc04ac46b
11
README.md
11
README.md
@ -8,6 +8,17 @@ You have to configurue it in the file nsupdate.config.
|
|||||||
|
|
||||||
## Changelog
|
## Changelog
|
||||||
|
|
||||||
|
**2014-01-2-02**
|
||||||
|
|
||||||
|
- 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
|
||||||
|
|
||||||
|
**2014-01-06**
|
||||||
|
|
||||||
|
- Config files are sourced relative to the script folder now
|
||||||
|
|
||||||
|
|
||||||
**2013-07-12**
|
**2013-07-12**
|
||||||
|
|
||||||
- First commit
|
- First commit
|
||||||
|
@ -1,10 +1,16 @@
|
|||||||
# nsupdate.config
|
# nsupdate.config
|
||||||
|
|
||||||
|
# from which site should we get your wan ip?
|
||||||
|
IP_CHECK_SITE="http://ifconfig.me/ip"
|
||||||
|
|
||||||
|
# use drill instead of nslookup for hostname lookup
|
||||||
|
USE_DRILL="NO"
|
||||||
|
|
||||||
# Login credentials for the inwx admin interface
|
# Login credentials for the inwx admin interface
|
||||||
INWX_USER="USERNAME"
|
INWX_USER="USERNAME"
|
||||||
INWX_PASS="PASSWORD"
|
INWX_PASS="PASSWORD"
|
||||||
|
|
||||||
# The hostname that you want to update and it's ID from the inwx interface
|
# The hostname that you want to update and it's ID from the inwx interface
|
||||||
# You get the ID when you edit the given nameserver entry and hover the save button.
|
# You get the ID when you edit the given nameserver entry and hover the save button.
|
||||||
HOSTNAME="subdomain.example.com"
|
DOMAIN="subdomain.example.com"
|
||||||
INWX_DOMAIN_ID="123456789"
|
INWX_DOMAIN_ID="123456789"
|
14
nsupdate.sh
14
nsupdate.sh
@ -24,14 +24,16 @@
|
|||||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
# 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
|
source $(dirname $0)/nsupdate.config
|
||||||
|
|
||||||
LOG=$0.log
|
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}\>'`
|
WAN_IP=`curl -s ${IP_CHECK_SITE}| grep -Eo '\<[[:digit:]]{1,3}(\.[[:digit:]]{1,3}){3}\>'`
|
||||||
|
|
||||||
API_XML="<?xml version=\"1.0\"?>
|
API_XML="<?xml version=\"1.0\"?>
|
||||||
@ -73,7 +75,7 @@ API_XML="<?xml version=\"1.0\"?>
|
|||||||
|
|
||||||
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) - $HOSTNAME updated. Old IP: "$NSLOOKUP "New IP: "$WAN_IP >> $LOG
|
echo "$(date) - $DOMAIN updated. Old IP: "$NSLOOKUP "New IP: "$WAN_IP >> $LOG
|
||||||
else
|
else
|
||||||
echo "$(date) - No update needed for $HOSTNAME. Current IP: "$NSLOOKUP >> $LOG
|
echo "$(date) - No update needed for $DOMAIN. Current IP: "$NSLOOKUP >> $LOG
|
||||||
fi
|
fi
|
Loading…
x
Reference in New Issue
Block a user