Many people have dynamic IPs on their consumer internet. Some things need to be updated after each IP change, e.g. dynamic DNS entries or tunnel endpoints for IPv6. Of course you could trigger an "update" every minute, but that would be silly, wouldn't it?
So this script compares the current IP (obtained from https://icanhazip.com/) with a previously stored IP and runs a set of scripts if the IP changed. The executed scripts will be called with the new IP as parameter.
Setting things up
Store the script under /usr/local/bin/react_to_ip_change.sh and create a directory for the update scripts named /usr/local/etc/ipchange.d/. All .sh-files in this directory will be executed if an IP change was detected.
To check regularly, just use your favourite cron.
The last IP will be stored in /tmp/ipaddress. To force an update run, just delete this file and call /usr/local/bin/react_to_ip_change.sh to test the update mechanism and once again to see what happens if nothing chaned.