I find that from time to time (I’m guessing after a power cycle or rest button press) my router reassigns ip address to all of my stuff. This doesn’t seem to bother printers or the machines running plain F35 Workstation, but one of my machines is running a website on a F35 Workstation with httpd, mariadb, php, etc. installed. The change in ip address means the server can’t serve anymore. Currently I just look at the address in GCC → Network then get it into the config file by doing the following:
# nano /var/www/html/sitename/wp-config.php Add or edit the following lines... define( 'WP_HOME','http://newip/sitename' ) ; define( 'WP_SITEURL', 'http://newip/sitename' ) ;
I want to automate this so I can just have a script that runs after a reboot and it’s all tanken care of.
I can get the ip address by running:
$ myip=`ip address | grep '192.168.1.255' | cut -d "/" -f1 | cut -d "t" -f2`
and $ echo $myip shows the current ip address, but I haven’t been able to figure out how to get the new ip address into the config file via a script.
First, is there a better way to get the ip address? Second, how can the script get the ip address into the config file? Third, is my approach wrong and I should do something else?