Change IP on a server
i'm forwarding, as requested, here, what i've asked in a ticket:
> Tom, do you know how can i change the IP EVERYWHERE on my server? If i use a standard recursive "sed" -see above-, it will substitute al symlinks with static files.
!/bin/sh
grep -rl OLDIP ./ |
while read filename
do
(
echo "Editing: $filename"
sed -i "s/OLDIP/NEWIP/g;" $filename
)
done
This is just because the initial grep, also searches in symlinks:
SRV:/etc/apache2/sites-enabled# grep -rl OLDIP ./
./00_master.conf
./ispcp.conf
SRV:/etc/apache2/sites-enabled#
As you can see, those files are symlinks:
SRV:/etc/apache2/sites-enabled# ls -lha
total 8.0K
drwxr-xr-x 2 root root 4.0K Aug 4 12:18 .
drwxr-xr-x 8 root root 4.0K Aug 4 12:15 ..
lrwxrwxrwx 1 root root 33 Aug 4 12:18 00master.conf -> ../sites-available/00master.conf
lrwxrwxrwx 1 root root 29 Aug 4 12:18 ispcp.conf -> ../sites-available/ispcp.conf
SRV:/etc/apache2/sites-enabled#
Any idea?
Have you ever done something similar?
Thankyou!
EDIT:
Found this in your documentation, but still have the same problem!
find ./ -type f -exec sed -i 's/98.76.54.32/12.34.56.78/' {} \;
2 Replies
> find ./ -type f -exec sed -i 's/98.76.54.32/12.34.56.78/' {} \;
.
That should not affect symlinks. Did you forget to change the normal files from your previous attempts back into symlinks?
> That should not affect symlinks. Did you forget to change the normal files from your previous attempts back into symlinks?
Thankyou, i'll try.
I've completely restored my system
Good, I confirm, it works:
> SRV:/etc/apache2/sites-enabled# ls -lha
total 8.0K
drwxr-xr-x 2 root root 4.0K Aug 4 12:18 .
drwxr-xr-x 8 root root 4.0K Aug 4 12:15 ..
lrwxrwxrwx 1 root root 33 Aug 4 12:18 00master.conf -> ../sites-available/00master.conf
lrwxrwxrwx 1 root root 29 Aug 4 12:18 ispcp.conf -> ../sites-available/ispcp.conf
SRV:/etc/apache2/sites-enabled# find ./ -type f
SRV:/etc/apache2/sites-enabled#
Maybe i've done something wrong in the initial test.