Script to detect dynamic ip change and update to config file

Hi All,

I am newbie here and request your assistance.

I have a service running on public ip, but since I have a dynamic IP it keeps on changing and every time I need to manually get the new ip and add to the config file and restart the service. This has become bit time consuming.

Hence, I am looking for a script that can do the following action.

Detect IP address in ppp0 whenever it changes -> capture the new IP address and update that to my config file and save -> Restart my service.

Thanking you.
Regards
Shaan

What operating system/distribution? It'd be preferred to put it in your ppp-up script, or ifup scripts if available.

CentOS 5.5

Thank you.
Shaan

Aside from how to invoke it, does the service config really needed changed? Could you possibly listen to 0.0.0.0 and just restart the service?

I don't deal with CentOS but I believe it has an ifup-local script. You could possibly just put service xxx restart in there.

To give details to modify the config file we'd have to know how it looks

Here's the config file. Wherever "PublicIP" appears, I need the ppp0 ip to be updated and save the file. I already have a "Start Service" and "Stop Service" script ready. So only difficulty is how to grab public ip from ppp0 whenever it changes and add that to the place of "PublicIP"

webproxy -l PublicIP -s local:127.0.0.1:7722 -F -L 501 -m 19001 -M 21000 -P PublicIP -B
Setstart -E -n 1 -l PublicIP -l 127.0.0.1 -W PublicIP

---------- Post updated 12-27-12 at 11:22 PM ---------- Previous update was 12-26-12 at 11:28 PM ----------

Any positive feedback from experts..