Jan 2, 2015

Dynamic DNS: adapting noipupdater.sh for MacOS

I often use my MacOS 10.8 laptop as a test server. In order to do this and to have other people easily accessing test services, I use a free Dynamic DNS entry from noip.com.
I don't want to install a big dyndns client of several MByte on my system, I prefer to have a nice small shell script which can be called regularly (in my case every 30 minutes) automatically as a service. Googleing gave me this nice bash script: noipupdater.sh (Link: github.com/mdmower/bash-no-ip-updater - Kudos!) Works like a charme when used as a service on a Mac, but the original one doesn't work with the "forced-update" feature. The reason is: the Bash of MacOS doesn't recognize the commands "tac" and "date -d". Googleing and a lot of testing gave me the following solutions (thanks to all the authors, I forgot to keep track of each suggestion):

Replace "tac" by "tail -r" and

use "date -jf "%Y-%m-%d %H:%M:%S" "$LASTGC" '+%s'" instead of "date -d ..."
With those replacements, the script works perfectly with the "forced-update" feature in order to avoid the free noip dns entry being deleted after 30 days.

No comments: