Update MediaWiki settings with dynamic IP address
That's nutty, trying to address a server by a changing IP address. Reconfiguring the wiki to adjust to it is even crazier.

The standard practice for adapting to dynamic IP addresses is to use a dynamic DNS service. Then, everything else works normally.


Pick a hostname, like afuna.noip.com. Run a DDNS client to register your hostname whenever you acquire a DHCP lease, and re-register that hostname periodically thereafter.
Use it to form the URL of your site, e.g. https://afuna.noip.com/.
Configure your MediaWiki setting using that URL once, and you won't need that hacky script anymore.