Recommendations for config file revision control

Roland Smith rsmith at xs4all.nl
Sat Jun 2 11:06:01 UTC 2007


On Fri, Jun 01, 2007 at 03:27:57PM -0400, Maxim Khitrov wrote:
>  Hi everyone,
> 
>  I'm currently setting up a new server, and I'd like to keep track of
>  all changes made to various config files (in /etc, /usr/local/etc, and
>  a few other places perhaps). My first thought was to setup a
>  subversion server which would contain the partial directory structure
>  that matches that of the server's starting at /. It would contain
>  versioned copies of all the configuration files that I want to keep
>  track of in their appropriate locations. What I would do then is write
>  a hook for subversion that will issue an automatic export command
>  (don't want .svn directories everywhere) every time a commit is made
>  to the repository. So to edit some configuration file I would first
>  checkout a working copy of the repository to some other location, make
>  the change and commit it. The server would be automatically updated
>  with the new file and I would be able to keep track of every change.

Because I didn't want my config file all over the place, I've put them
in a directory tree called ~/setup, with subdirectories for etc, boot,
kernel configuration etc.

This directory tree is managed with git, because you don't have to check
in every single file like with RCS. So e.g. all the changes that I did
for the Xorg upgrade are captured in a single commit. Since git doesn't
support keyword expansion, and I always use emacs for editing, I use
emacs's time-stamp facility to keep the time and date of the last save.

I use an install script to install the config files where they belong,
and take appropriate post-install action.

One could put the directories like /etc under git's direct control as
well. That would save the installation step, and capture any system-made
modifications with git-status. But you'd have to manage the repository
as root.

----------------- install script for /etc config files ----------------------
#!/bin/sh
# Shell script to facilitate installing files.
# Time-stamp: <2007-05-20 21:32:43 rsmith>

# Installs a normal file.
I () {
    install -b -v -p -m 644 $1 $2 |grep install || {
        return 1
    }
}

# Files that need to be installed as root go here.
do_root() {
    I devfs.conf /etc
    I devfs.rules /etc
    I fbtab /etc
    I fstab /etc
    I passwd /etc
    I group /etc
    I hosts /etc
    I login.conf /etc && cap_mkdb /etc/login.conf
    I csh.cshrc /etc
    I cshrc.root /root/.cshrc
    I login.access /etc
    I locate.rc /etc
    I manpath.config /etc
    I motd /etc
    I periodic.conf /etc
    I pkgtools.conf /usr/local/etc
    I portmaster.rc /etc
    I profile /etc
    I rc.conf /etc
    I pf.conf /etc && /etc/rc.d/pf reload
    I ntp.conf /etc && /etc/rc.d/ntpd restart
    I rc.shutdown.local /etc
    I resolv.conf /etc
    I sysctl.conf /etc
    I ttys /etc
    I make.conf /etc
    I newsyslog.conf /etc
    I mtools.conf /usr/local/etc
    I smartd.conf /usr/local/etc
    I cdrecord /usr/local/etc
    I esd.conf /usr/local/etc
    # X11 config files
    cd X11
    I xorg.conf /etc/X11
    cd ..
    # SANE config files.
    cd sane
    I dll.conf /usr/local/etc/sane.d
    I epson.conf /usr/local/etc/sane.d
    cd ..
    # Install root's crontab file
    if ! crontab -l|diff - crontab.root >/dev/null; then
        echo "Updating crontab."
        crontab -u root crontab.root
    fi
}

# Main program
if [ `id -u` -eq 0 ]; then
    do_root
fi
----------------- install script for /etc config files ----------------------

Roland
-- 
R.F.Smith                                   http://www.xs4all.nl/~rsmith/
[plain text _non-HTML_ PGP/GnuPG encrypted/signed email much appreciated]
pgp: 1A2B 477F 9970 BA3C 2914  B7CE 1277 EFB0 C321 A725 (KeyID: C321A725)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20070602/d80586d2/attachment.pgp


More information about the freebsd-questions mailing list