Posting WAN Raspberry Pi IP address to emoncms - dev test idea

Recently I have been testing controlling my heating system from emoncms running on a local raspberry Pi:

This works great when I'm in the house (although I still need to work on a front-end UI), maybe this heating scheduler could be integrated: ?

I have opened http port on my router to give me access to emoncms on my local Pi from anywhere on the internet. This works well, although since I don't have any form dynamic DNS setup my WAN IP regularly changes. Setting up a dynamic DNS would solve this problem but since the Pi is also posting my data to a remote emoncms server I though why not get it to post it's external WAN IP to the remote emoncms as a number of feeds.

Here is a bash script I wrote to do just that, I'm a beginner when it comes to programming to please point out if you think this could be done easier.

The setup I've got working does require a small php script which returns the users IP to be put on the remote server. This script is then called from the local Pi and the IP address posted back to the remote server as four integer feeds. I set this script to run as cron ever couple of hours. 

Maybe something like this could form the basis of an emoncms Module in the future. I think it would also be very useful for people installing energy monitoring systems based using the Pi as an emonbase and require remote ssh access for debugging, updating etc

: <<'END'
Place the following PHP script as IP.php in the root directory of your remote server to return the users IP address

//Gets the IP address
$ip = getenv("REMOTE_ADDR") ;
Echo $ip;
NODE_ID=30  #node ID for WAN IP to be posted to

WANIP=`wget -q -O - $URL/ip`

arr=$(echo $WANIP | tr "." "\n")
for x in $arr

echo ${IP[*]}

curl --request GET "$URL$PATH_TO_EMONCMS/input/post.json node=$NODE_ID&csv=${IP[1]},${IP[2]},${IP[3]},${IP[4]}&apikey=$API"