[K12OSN] How to change X-terminales networks

Julius Szelagiewicz julius at turtle.com
Wed Oct 22 15:08:00 UTC 2008


Actually, you can edit in place; sed -i 's ...' myconfigfile.txt

On Wed, 22 Oct 2008, Rob Owens wrote:

> I'm not an expert on the syntax, but I know you can use 'sed' for this.
>  It'll find and replace text in any file.  Something like:
>
> sed s/192.168.0.254/192.168.10.1/g myconfigfile.txt > myconfigfile.txt.2
>
> That'll find the first IP address in myconfigfile.txt, and replace it
> with the 2nd IP address in myconfigfile.txt.2 -- you'll then have to
> delete the original config file and replace it with the new one.
>
> You could probably put together a script that does a recursive grep
> (grep will find text in a file) and the run sed on that file.  This is
> probably wrong, but it might go something like this:
>
> #!/bin/bash
>
> # Change these variables to suit your needs
> OLDIP=192.168.0
> NEWIP=192.168.10
> SEARCHDIR=/etc
>
> for FILE in `ls -R $SEARCHDIR`
> do
> 	grep $OLDIP $FILE
> 	if [ $? == 0 ]; then
> 		sed s/$OLDIP/$NEWIP/g $FILE > $FILE.new && mv -f $FILE.new $FILE
> 	fi
> done
>
> I'm very much a beginner at scripting, and I didn't even test this, so
> wait and see what the scripting masters on this list say before using
> this.  And make sure you test it on a non-production system.
>
> -Rob
>
> Arturo Limón wrote:
> > Hello,
> >
> > I am preparing a "standar server" for schools with k12ltsp over CentOS.
> > It runs over Linux RAID, so cloning the server for similar hardware is
> > quite easy.
> >
> > BUT, I have a problem with networking. I am preparing the server for
> > network 192.168.1.x, but when I have to install it in schools, quite
> > often I find that their network is in the range 192.168.0.x, or
> > 192.168.10.x or any other different from the one I have prepared. As far
> > as the server will not only server "dumb" terminals (old computers) but
> > also real computers for services like http, samba, dns, and others, I
> > may need to change my net range from 192.168.1.x to theirs, better than
> > changing IPs to serveral tens computers scattered all over the building
> > (something that they frecuently do not like).
> >
> > But changing it has proved to be not an easy task. Lots of configuration
> > files are involved. I have seen all those files are created and/or
> > correctly configured on installation, but changing them after than needs
> > a lot of handwork, I have tried with ltspadmin, but I only solves part
> > of the problem.
> >
> > So, my question is:
> >
> > Is there an easy way to "say" to the system, "network is not 192.168.1.x
> > any more, now is 192.168.0.x", and get all the involved files changed or
> > recreated accordingly, like in installation happens ?
> >
> > Thanks.
> >
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > K12OSN mailing list
> > K12OSN at redhat.com
> > https://www.redhat.com/mailman/listinfo/k12osn
> > For more info see <http://www.k12os.org>
> ********************************************************
>
> The information transmitted is intended only for the person or entity to
> which it is addressed and may contain confidential and/or privileged
> material. If you are not the addressee, any disclosure, reproduction,
> copying, distribution, or other dissemination or use of this transmission in
> error please notify the sender immediately and then delete this e-mail.
> E-mail transmission cannot be guaranteed to be secure or error free as
> information could be intercepted, corrupted lost, destroyed, arrive late or
> incomplete, or contain viruses.
> The sender therefore does not accept liability for any errors or omissions
> in the contents of this message which arise as a result of e-mail
> transmission. If verification is required please request a hard copy
> version.
>
> ********************************************************
>
>
> _______________________________________________
> K12OSN mailing list
> K12OSN at redhat.com
> https://www.redhat.com/mailman/listinfo/k12osn
> For more info see <http://www.k12os.org>
>





More information about the K12OSN mailing list