SourceFiles.org - Use the Source, Luke
Home | Register | News | Forums | Guide | MyLinks | Bookmark

Related Sites

Latest News
  General News
  Reviews
  Press Releases
  Software
  Hardware
  Security
  Tutorials
  Off Topic


Back to files

# cfgarch v0.3 - a config archiver utilizing subversion # Copyright (C)2004, Torsten Fellhauer
#
# This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 1, or (at your option) # any later version.
#
# This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. #
# You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

CFGARCH

  1. Description
  2. Prerequisites
  3. Configuration file
  4. Running cfgarch
  5. Using WebSVN with cfgarch

1) DESCRIPTION

Cfgarch is a simple tool for storing configuration files of multiple hosts and also using revision control features of a versioning system like subversion.

After evaluating all files and directories to be transferred from the remote systems, cfgarch transfers the files by ssh and checks for changes compared to the files already in the repository. After doing a svn commit, a summarization of all changes will be printed to STDOUT.

2) PREREQUISITES

  • Install a current subversion version
    • install both the client and the server component of subversion.
    • for more detailed installation instructions, please refer to the subversion manual available on http://subversion.tigris.org.
  • Create a subversion repository
    • svnadmin create /path/to/configrepository
  • Create a user for cfgarch
    • useradd cfgarch
  • Create ssh-keys with forced command for both pushing and pulling data from the hosts.
    • ssh-keygen -t rsa -f ~/.ssh/cfgarch-pull
    • insert the following string at the first position of the public key file ~/.ssh/cfgarch-pull.pub command="tar -cf - -T cfgarch.files"
    • ssh-keygen -t rsa -f ~/.ssh/cfgarch-push
    • insert the following string at the first position of the public key file ~/.ssh/cfgarch-push.pub command="tar -xf - "
  • Distribute the public keys to the hosts you want to get the configuration files from to the file ~root/.ssh/authorized_keys.
  • For more informations regarding usage of ssh public key authentication, please refer to the documentation available on http://www.openssh.org.

3) CONFIGURATION FILE

The configuration file (default: cfgarch.conf) can contain three different section types: GLOBAL, TYPE and HOST. The section [GLOBAL] contains all global configuration options like directories or timeouts, whereas the [TYPE] sections contain definitions of types that can be referred by individual hosts. Finally [HOST] sections contain the types assigned to a host as well as additional files and directories to be stored.

[GLOBAL] section

  • Define the paths to the required binaries
    • TAR_BINARY=/path/to/tar
    • SSH_BINARY=/path/to/ssh
    • SVN_BINARY=/path/to/svn
  • Specify the path to repositories
  • Specify the path to working directory and temporary directory
    • CFGARCH_WORKDIR=/path/to/working-directory
    • CFGARCH_TEMPDIR=/path/to/temporary-directory
  • Specify the paths to the SSH private keys
    • SSH_PULLKEY=/path/to/cfgarch-pull
    • SSH_PUSHKEY=/path/to/cfgarch-push
  • Define whether to use SSH version 1 or 2 depending on the keys built before
    • SSH_VERSION=2
  • Define timeout of ssh operations to avoid hanging ssh connections
    • SSH_TIMEOUT=10

[TYPE] section

  • Define the name of the individual type
    • NAME=mytype
  • Define the files to be transferred by each host assigned to this type
    • FILE=/path/to/first/file
    • FILE=/path/to/second/file
  • Define the directories to be transferred by each host assigned to this type
    • DIR=/path/to/first/directory
    • DIR=/path/to/second/directory

[HOST] section

  • Define the name of the individual host
    • NAME=myhost
  • Specify the user to be used by ssh to transfer the files and directories. In order to be able to get all files, this user should be root.
    • USER=root
  • Define the types to be assigned to this host.
    • TYPE=mytype1
    • TYPE=mytype2
  • Define the files to be transferred by this host assigned to this type
    • FILE=/path/to/first/file
    • FILE=/path/to/second/file
  • Define the directories to be transferred by this host assigned to this type
    • DIR=/path/to/first/directory
    • DIR=/path/to/second/directory

4) RUNNING CFGARCH

Simply change to the directory of cfgarch and execute it without specifying command line options:

  • ./cfgarch <RETURN>

If there are any problems, run cfgarch with option -d, which enables debugging output. Simply send me the debug output by mail and I will try to help you solving the problem.

Commandline options:

The following commandline options can be used with cfgarch:

 -h           -> display usage information
 -d           -> display debug output

-c <cfgfile> -> use a non-default configuraton file

Automatic execution using cron:

For regularly transferring configuration files using cfgarch, it's recommended to use cron for a regular execution. The output of cfgarch the could be sent to the administrators by mail. The following line show a example crontab entry:

0 1 * * * cfgarch /path/to/cfgarch \

              -c /path/to/cfgarch.conf \
              | /usr/bin/mail -s "cfgarch summary" \
              recipient@company.com 

5) USING WEBSVN WITH CFGARCH

If you need a web-based tool for accessing the cfgarch repository, you can use WebSVN, which is available on http://websvn.tigris.org.

Installation and configuration of WebSVN is explained in detail in the README file of WebSVN. But I faced some problems in setting up WebSVN, whereas I decided to add some documentation to this README.

Problem: Cannot access repository
Solution: WebSVN needs write access to the DB files of

          the repository. Therefore the webserver 
          instance should run under the same user as
          cfgarch.

Problem: Error-message "undefined function

html_entity_decode"
Solution: Get package PHP_Compat from http://pear.php.net

          and copy the file html_entity_decode.php into
          the WebSVN/include directory. Then insert the 
          following line at the beginning of 
          WebSVN/include/setup.inc:
            require_once("include/html_entity_decode.php");

Problem: Error-message "Cannot set LC_CTYPE" Solution: On some installations, subversion commands

          cannot be executed when environment variables
          LANG or LC_CTYPE are set to values other than
          "C". Then insert the following lines at the 
          beginning of WebSVN/include/setup.inc:
            putenv("LANG=C");
            putenv("LC_CTYPE=C");


Other Sites

Discussion Groups
  Beginners
  Distributions
  Networking / Security
  Software
  PDAs

About | FAQ | Privacy | Awards | Contact
Comments to the webmaster are welcome.
Copyright 2006 Sourcefiles.org All rights reserved.