Perl
  Home arrow Perl arrow Page 2 - Cultured Perl: Managing Linux Configur...
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PERL

Cultured Perl: Managing Linux Configuration Files
By: developerWorks
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 6
    2004-11-24

    Table of Contents:
  • Cultured Perl: Managing Linux Configuration Files
  • Setting up CVS
  • Automatic updates and commits
  • Organizing your new configuration
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
     
    ADVERTISEMENT

    Route your faxes to your email inbox. Private, secure fax numbers available from CallWave. Choose your fax number.

    Cultured Perl: Managing Linux Configuration Files - Setting up CVS
    (Page 2 of 5 )

    You probably already have CVS installed on your machine. If not, get it (see the Resources section) and install it. If you are using another versioning system, try to set up something similar to what I show below.

    First of all, you need to create a CVS repository. I'll assume you have access to a machine that can be used as a CVS server through OpenSSH or Pserver CVS access (Pserver is the communication protocol for CVS; see Resources for more information). Then, you need to create a module called config, which I will use to hold the sample configuration files. Finally, you need to arrange a way to use your CVS repository remotely non-interactively, through OpenSSH, Pserver, or whatever is appropriate. This last point is highly dependent on your particular system administration skills, level of paranoia, and environment, so I can only point you to some information in the Resources. I will assume you have configured non-interactive (ssh-agent) logins through OpenSSH for the rest of this article.

    Listing 1. Set up the CVS repository on a machine

    # assume that /cvsroot is your repository's home
    > setenv CVSROOT /cvsroot
    # this will use $CVSROOT if no -d option is specified
    > cvs init
    # check that it worked
    > ls /cvsroot
    # you should see one directory called CVSROOT
    CVSROOT

    Now that the repository is set up, you can continue using it remotely (you can do the steps below on the CVS server, too -- just leave CVSROOT as in Listing 1).

    Listing 2. Remotely add the config module to CVS

    # user tzz, machine home.com, directory /cvsroot is the CVSROOT
    > setenv CVSROOT
    tzz@home.com:/cvsroot
    # use SSH as the transport
    > setenv CVS_RSH ssh
    # use a temporary directory for the module creation
    > cd /tmp
    > mkdir config
    > cd config

    # tzz is the "vendor name" and initial is the "release tag", they can
    # be anything; the -m flag tells CVS not to ask us for a message

    # if this fails due to SSH problems, see the Resources
    > cvs import -m '' config tzz initial
    No conflicts created by this import
    # now let's do a test checkout
    > cd ~
    > rm -rf /tmp/config
    > cvs co config
    cvs checkout: Updating config
    # check everything is correct
    > ls config
    CVS

    Now you have a copy of the config CVS module checked out in your home directory; we'll use that as our starting point. I'll use my user name tzz and home directory /home/tzz in this article, but, of course, you should use your own user name and directory as appropriate.

    Let's create a single file. The CVS options file, cvsrc, seems appropriate since we'll be using CVS a lot more.

    Listing 3. Create and add the cvsrc file

    > cd ~/config
    > echo "cvs -z3" > cvsrc
    > echo "update -P -d" >> cvsrc
    > cvs add cvsrc
    # you really don't need log messages here
    > cvs commit -m ''
    > ln -s ~/config/cvsrc ~/.cvsrc

    From this point on, all your CVS options will live in ~/config/cvsrc, and you will update that file instead of ~/.cvsrc. The specific options you added tell CVS to retrieve directories when they don't exist, and to prune empty directories. This is usually what users want. For the remaining machines you want to set up this way, you need to check out the config module again and make the link again.

    Listing 4. Check out the config module and make the cvsrc link

    > cd ~
    # set the following two for remote access
    > setenv CVSROOT ...
    > setenv CVS_RSH ...
    # now check out "config" -- this will get all the files
    > cvs checkout config
    > cd ~/config
    > ln -s ~/config/cvsrc ~/.cvsrc

    You may also know that Linux allows for hard links in addition to the symbolic ones you just created. Because of the limitations of hard links, they are not suitable to this scheme. For instance, say you create a hard link, ~/.cvsrc, to ~/config/cvsrc and later you remove ~/config/cvsrc (there are many ways this could happen). The ~/.cvsrc file would still hold the old contents of what used to be ~/config/cvsrc. Now, you check out ~/config/cvsrc again. The ~/.cvsrc file, however, will not be updated. That's why symbolic links are better in this situation.

    Let's say you change cvsrc to add one more option:

    Listing 5. Modify and commit cvsrc

    > cd ~/config
    > echo "checkout -P" > cvsrc
    > cvs commit -m ''

    Now, to update ~/.cvsrc on every other machine you use, just do the following:

    Listing 6: Modify and commit cvsrc

    > cd ~/config
    > cvs update

    This is nice and easy. What's even nicer is that the CVS update shown above will update every file in ~/config, so all the files you keep under this CVS scheme will be up-to-date at once with one command. This is the essence of the configuration scheme shown here; the rest is just window dressing.

    Note that once you've checked out a module, there's a directory in it called "CVS." The CVS directory has enough information about the CVS module that you can do update, commit, and other CVS operations without specifying the CVSROOT variable.

    IBM developerWorksVisit developerWorks for thousands of developer articles, tutorials, and resources related to open standard technologies, IBM products, and more. See developerWorks.

    More Perl Articles
    More By developerWorks


     

       

    PERL ARTICLES

    - Perl: A Continuing Look at Hashes and Multid...
    - Perl: Another Round with Hashes
    - Perl Hashes
    - Perl Lists: A Final Look at List::Util
    - Perl Lists: Utilizing List::Util
    - Perl Lists: The Split() Function
    - SQL and CGI with Perl and DBI
    - Perl Lists: More Functions and Operators
    - SELECT Queries and Perl
    - Perl Lists: More on Manipulation
    - Creating a Database with Perl and DBI
    - Perl: Sailing the List(less) Seas
    - Perl and DBI
    - Perl: Concatenating Text and More
    - Perl Text: Quoting Without Quote Marks

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway