Track server configuration file changes using Git versioning system
BY sujith.s
7 years ago
comments comment

When a server is managed by more than one admin, it’s always a challenge to keep track of the changes made to the configuration. And when in a multiserver environment managed by more than one admin, this is going to be more complex. It would have been much saner if there was a utility to handle all this. The ones that we found were quite complicated and was made for handling huge numbers. All we wanted was a very simple utility to do just the job, without much bells and whistles. And so, we started out on our own. Here’s what we have now.

We were using the Git for our Drupal code base version controlling. We thought the same could be made use of for system configuration file versioning. We created a bash script that did just that and scheduled it to execute once every hour.

The script compares configuration files with the ones we have in the git repo, and if changes are found, it copies them to a directory called conf and adds the changes to git. It reads the details of files to be tracked from a configuration file kept for the same.

Cron was used for scheduling jobs.

The script can run both as root as well as any normal user.

If the script finds any difference it sends out an email to the recipient address stored in the script.

The script requires that you have a git server and that you have already created a repo for the same.

Here is the script (you might have to modify the email, hostname variables):. You can also follow this at




 # Debug function
function db {
  if [ $DEBUG -eq 1 ];
    echo "$1"

# Log function
function log {
  # If there are parameters read from parameters
  if [ $# -gt 0 ]; then
    echo "[$(date +"%D %T")] $@" >> $LOG_FILE
    db "$@"
    # If there are no parameters read from stdin
    while read data
      echo "[$(date +"%D %T")] $data" >> $LOG_FILE
      db "$data"

# Change to the dir this script resides in
script_path=`readlink -f $0`
script_dir=`dirname "$script_path"`
cd "$script_dir"
 # Run copy operations if run as root
if [ $(id -u) -eq 0 ]; then
  db "Running copy operations"
  # Copy files to the conf folder
  while read path
    # Ignore comments and empty lines
    echo "$path" | egrep '(^\s*#)|(^\s*$)' >/dev/null 2>&1 && continue
    db "$path read from the file"
    if [ -f "$source" ]; then
      # If file then copy
    elif [ -d $source ]; then
      # If folder then deep copy
      destination="`dirname \"$destination\"`"
      # Create the destination folder if it does not exist
      if [ ! -d "$destination" ]; then
        log "$destination does not exist. Creating dir"
        mkdir -p "$destination"
      log "$path: Illegal path found."
      # Continue on to the next path
    db "Copying $source to $destination"
    (nice cp $param "$source" "$destination" 2>&1) | log
  done < ./`hostname`.conf
  db "Changing ownership of conf/`hostname` to metheuser"
  chown -R metheuser: metheuser "conf/`hostname`"
 # Run git operations if run as normaluser
  db "Running git operations"
  # Run git diff to find changes
  file_diff=`git diff --no-prefix`
  diff_lines=$(($(echo -n "$file_diff" | wc -l)))
  # Run git status to check if untracked files are present
  git status|grep untracked > /dev/null
  if [ $? -eq 0 ]; then
    git_status=`git status`
  # If there is a difference
  if [[ $diff_lines -gt 0 || $has_untracked -eq 1 ]]; then
    log "$diff_lines line(s) of difference found"
    log "Has untracked = $has_untracked"
    # Get latest changes from other servers
    log "Pulling changes (if any) from server"
    (git pull 2>&1) | log
    # Commit the difference on the machine
    (git add -A 2>&1) | log
    (git commit -m "Adding changes from $(hostname)" 2>&1) | log
    (git push 2>&1) | log
    db $file_diff
    subject="[CONFIG-TRACK] `hostname` - Status Report - $(date)"
    git_differences="`echo -e "$file_diff\n$git_status"`"
    log "Sending differences via email"
    log "$git_differences"
    echo -e "$git_differences" | mail -s "$subject" -c $email_cc_address $email_to_address 2>&1 | log
    db "No differences found"



on 30th March 2007 / by webmaster
Ever since we started our pc sales and services division we have been trying to get a system with Hardware Linux Leave a reply Your email address will not be published. Required fields are marker * Cherry (not verified) access_time 20 Jul 2019 - 07:14 Is that true ? Are there many people who still use modems to dialup internet ? I was thinking of helping out with some limited internal modem support for NetBSD, but wasn’t sure what the user base is like. Anoop John (not verified) access_time 20 Jul 2019 - 07:14 Yes I have come across quite a few customers who still use dialup as the only means of accessing net. For people who just use internet to check mail, dialup is the cheapest way to go. shankar (not verified) access_time 20 Jul 2019 - 07:14 I have read your above article. I have the same problem. I want to use the new Bharatiya Operating System Solution (BOSS) which is linux based. My dial up modem of D-Link is not detected in linux/BOSS neither I can get a driver for linux. D-Link company have informed that they do not have any modem supporting linux. Please inform whether you can send it by post, cost and methods available for payment. regards, shankar Add new comment

on 04th April 2007 / by webmaster
Linux is the epitome of the FLOSS model. Linux Leave a reply Your email address will not be published. Required fields are marker * Dewey J. Corl (not verified) access_time 20 Jul 2019 - 07:32 Linux is not ready for the general public! (I am a Ubuntu user). For proof, 1. try to simply print labels on a Dymo label printer. It takes a LOT of work to get to the ease of label printing already available in Windows and Mac. 2. try syncing a modern Palm based PDA. Yes, jpilot and others will sync the main data, but pictures and midi files do not get transferred without a lot of extra setup. These are examples of applications that are not ready for the general public. Since an operating system only supports applications, Linux is not ready to be a common desktop for the general public. While we are waiting for the applications to catch up, keep up the good work!! Anoop John (not verified) access_time 20 Jul 2019 - 07:32 Dewey Yes you may be right. But these are not applications that a common man would use. A common man would use one of these applications - Internet browser, Chat Client, Email Client, Document Writer, Presentation Creator, Spreadsheet Editor, Movie Viewer, Music Player, CD/DVD Writer. Both examples you cited are more specific applications that only a small percentage of the whole population uses. It will take time before those hardware vendors identify the need from their perspective to address the Linux community. Krishnadas (not verified) access_time 20 Jul 2019 - 07:32 Dear Mr Anoop, Thank you very much for the free installation of LINUX done in my PC. I am getting immersed in the LINUX and seeing the versatility. To my surprise, I am able to read one of my old backup CD(wherein lot of my valuable file exist) done in DIRECT CD wizard (a custom cd writing software of Easy Cd creator in WIN98) which could not be read in XP. Installation of old version of easycd creator/direct cd program was not possible in XP. I thought that possible i lost all data. Very pleasant start! Srikanth N. S. (not verified) access_time 20 Jul 2019 - 07:32 Hi Anoop, My friend is thrilled with Ubuntu. One of his grouses with windows was that after OS installation, everything else is to be installed separately which is a real headache. WHereas if u install Linux, everything is installed as a package and he is thrilled to bits! Let linux installation spread in Trivandrum and your service in this direction is highly appreciated. Kepp up the good work Regards. PDA Freak (not verified) access_time 20 Jul 2019 - 07:32 Is it possible to install linux on a packardbell notebook ? Pagination Current page 1 Page 2 Next page Next › Last page Last » Add new comment

on 20th April 2007 / by webmaster
Linux has been growing in leaps and bounds in terms of internationalization. Linux Malayalam Open Source Ubuntu Leave a reply Your email address will not be published. Required fields are marker * Ranjith Antony (not verified) access_time 20 Jul 2019 - 13:08 Everything is fine an dandy. However, to read those websites which doesn't support unicode fonts you have to install padma firefox extension . Those websites include all malayalam newspaper websites including, deepika, manorama, keralakaumudi etc. These websites only support truetype fonts. TrueTypes are glyphs matching a malayalam character but doesn't have a hex code assigned to it. They use ASCII character set but with a different glyph. Just to read malayalam, you only need to perform the first 3 steps in Peringodan's blog, in addition to the hacks thats been explained in this blog post. PS: Its so funny; a tutorial to explain how to install malayalam read and write support is written in malayalam. Thats what called a chicken and egg problem. Cherry (not verified) access_time 20 Jul 2019 - 13:08 I’d like to point out a couple of things: a) Malayalam support is not an Ubuntu thing or a Linux thing… I am running NetBSD -current on my laptop with and I can type malayalam. Learning the key combinations is very easy and intuitive… it just requires attention and commitment. I learnt it in about a week and something. b) Mangleesh support for TeX has been around for a while. The TuX group in Trivandrum and specifically A.J.Alex have worked on very good quality latex support for malayalam. See: Just to set the record. Cheers, Cherry. vimal access_time 20 Jul 2019 - 13:08 Ready to use packages to support malayalam in Ubuntu 7.10 and Debian GNU/Linux Etch is available at . Add new comment
Leave a reply
Your email address will not be published. Required fields are marker *

Filtered HTML

  • Web page addresses and email addresses turn into links automatically.
  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type='1 A I'> <li> <dl> <dt> <dd> <h2 id='jump-*'> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
The content of this field is kept private and will not be shown publicly.
CAPTCHA This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.

Anonymous (not verified)
access_time 20 Jul 2019 - 13:46

Thanks it is exactly what I'm looking for.