Linode Forum Index Linode Forum
Linode Community Forums
 


Change IP on a server

Click here to go to the original topic

 
       Linode Forum Index -> Linux Tips, Tricks, Tutorials
Author Message
solounaltronick



Joined: 20 Aug 2009
Posts: 13

Posted: Fri Aug 21, 2009 12:56 am    Post subject: Change IP on a server  

Hi Forum,

i'm forwarding, as requested, here, what i've asked in a ticket:

Quote:
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 00_master.conf -> ../sites-available/00_master.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/' {} \;
Back to top  
saman007uk



Joined: 16 Oct 2004
Posts: 168

Posted: Fri Aug 21, 2009 10:44 am    Post subject:  

Quote: 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?
Back to top  
solounaltronick



Joined: 20 Aug 2009
Posts: 13

Posted: Mon Aug 24, 2009 2:29 am    Post subject:  

Quote: 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 :D

Good, I confirm, it works:

Quote: 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 00_master.conf -> ../sites-available/00_master.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.
Back to top  
 
       Linode Forum Index -> Linux Tips, Tricks, Tutorials
Page 1 of 1