I run some websites at home and periodically my IP changes. I'm working on a shell script to run on cron that will check my IP every 12 hours and update it if needed.
I'll admit I'm not much of a programmer, but here is what I've come up with so far:
#!/bin/bash
publicip=`curl -s http://whatismyip.org/`
/root/ednsupdater -u username -p password -ip $publicip -d mydomain1.com
/root/ednsupdater -u username -p password -ip $publicip -d mydomain2.com
/root/ednsupdater -u username -p password -ip $publicip -d mydomain3.com
As you can see, I pull my public IP and assign it to a variable named $publicip and pass it on to another script which updates the DNS service I use.
What I would like to do is something like this, but I'm not sure of the syntax I would use:
if $public has changed, then execute the ednsupdater script, otherwise do nothing
I'd also like to add support to send me an email if it has changed, possibly even write something to syslog? I'm thinking some if then else statements would do what I need, but I'm not well versed enough to write them correctly.....
I'll admit I'm not much of a programmer, but here is what I've come up with so far:
#!/bin/bash
publicip=`curl -s http://whatismyip.org/`
/root/ednsupdater -u username -p password -ip $publicip -d mydomain1.com
/root/ednsupdater -u username -p password -ip $publicip -d mydomain2.com
/root/ednsupdater -u username -p password -ip $publicip -d mydomain3.com
As you can see, I pull my public IP and assign it to a variable named $publicip and pass it on to another script which updates the DNS service I use.
What I would like to do is something like this, but I'm not sure of the syntax I would use:
if $public has changed, then execute the ednsupdater script, otherwise do nothing
I'd also like to add support to send me an email if it has changed, possibly even write something to syslog? I'm thinking some if then else statements would do what I need, but I'm not well versed enough to write them correctly.....