User Tools

Site Tools


Storing Open Source Configs in Mercurial

  • One of the best features about revision control systems is that nothing is ever deleted, so it would be really handy to store server configs in a distributed revision control system like mercurial. The following is one way this can be accomplished without the administrator is remember to run commits
  1. create a script /scripts/
    export PATH=${PATH}:/usr/local/sbin:/usr/local/bin
    function commit_dir {   if [ -d ${1} ]
                    cd ${1}
                    if [ ! -d .hg ]
                            hg init
                    hg addremove
                    hg commit --config ui.username="`hostname`" -m "Update `date`"
    commit_dir /etc/
    commit_dir /usr/local/etc/

    This script will init a repo to the two etc dirs and update the repo as changes are made to the config in each directory. You can add new entries at the bottom of the script to have make mercurial repos for more config directories.

  2. Next link the script /scripts/ to one for the periodic directories or made a entry in /etc/crontab.

Setup Script

mkdir /scripts
cd /scripts
wget -O
chmod 755
cd /etc/cron.daily
ln -s /scripts/
ubuntu/merc_etc.txt · Last modified: 2015/05/05 12:59 by tschulz