stecklars / dynamic-dns-netcup-api

A simple dynamic DNS client written in PHP for use with the netcup DNS API.
MIT License
178 stars 55 forks source link

Allow executing external command if IP has changed #31

Open OevreFlataeker opened 3 months ago

OevreFlataeker commented 3 months ago

I would like to document the changes of my external IP and perform some action once then change. Though I could as well write my own "detection script", I'd rather use your tool, because all the detection logic is already there.

I'd fancy an cmdline arg which allows to specify an external command (i.e. another bash script) that will get called once an ip changed:

The relevant code portion (for IPv4) would probably be:

            if ($ipv4change === true) {
                $foundHostsV4[0]['destination'] = $publicIPv4;
                //Update the record
                if (updateDnsRecords($domain, CUSTOMERNR, APIKEY, $apisessionid, $foundHostsV4)) {
                    outputStdout("IPv4 address updated successfully!");
                } else {
                    exit(1);
                }

Ideally the new IP should be given as a cmd line argument to the command.

Thanks for considering