Linux Training

Linux training for private, public & voluntary sector.

0800 024 8425

City LinUX Training Courses

Section 22.
Change control
.


"I’m an egotistical bastard, and I name all my projects after myself. First ’Linux’, now ’git’."

Linus Torvald.

22. Change control.

Whenever we make changes to configuration files or systems administration scripts we need to keep an accurate record of what we did, when and why. If the change doesn’t work out or has an unexpected impact somewhere else in the system, we need to be able to roll back to the previous settings.

There are many tools within Linux which allow us to do this with a minimum of fuss and bureaucracy. The old Source Code Control System or sccs which was developed at Bell Labs and was available in System V derived distributions provided this functionality very simply but remained proprietary until released under the Open Solaris project. I understand that GNU’s cssc is available as a replacement for sccs.

The sccs command set is part of the Single Unix Specification.

The Revision Control System (rcs) was developed at Purdue University and first released in 1982. rcs is available in all Linux distributions that I know of and if anything is easier to use than sccs.

I don’t like the format of the headers that rcs produces but I can live with it to have a tool that can remove all those backup copies with extraordinary and uninformative names that litter many corporate systems. e.g.

sa101$ cd /etc/mail
sa101$ ls
Makefile      diffs             relay-domains          sendmail.old
Makefile.new  domaintable       sendmail+dkim-masq.cf  spamassassin
access        domaintable.db    sendmail-dkim.cf       statistics
access.db     genericstable     sendmail.bill            submit.cf
access~       genericstable.db  sendmail.cf            submit.cf.new
aliases       helpfile          sendmail.cf.121001     submit.cf1201003
aliases.db    local-host-names  sendmail.cf.dkim       trusted-users
aliases.new   mailertable       sendmail.cf.new        virtusertable
aliases~      mailertable.db    sendmail.cf1201003     virtusertable.db
current.cf    masqdomains       sendmail.keepthisone

We can create a backup copy of our target file instantly with ci, rcs’s check in command.

sa101$ cd /etc/mail
sa101$ sudo ci sendmail.cf
sendmail.cf,v  <--  sendmail.cf
enter description, terminated with single ’.’ or end of file:
NOTE: This is NOT the log message!
>> .
initial revision: 1.1
done
sa101$ ls
Makefile      diffs             relay-domains          sendmail.old
Makefile.new  domaintable       sendmail+dkim-masq.cf  spamassassin
access        domaintable.db    sendmail-dkim.cf       statistics
access.db     genericstable     sendmail.bill          submit.cf
access~       genericstable.db  sendmail.cf,v          submit.cf.new
aliases       helpfile          sendmail.cf.121001     submit.cf1201003
aliases.db    local-host-names  sendmail.cf.dkim       trusted-users
aliases.new   mailertable       sendmail.cf.new        virtusertable
aliases~      mailertable.db    sendmail.cf1201003     virtusertable.db
current.cf    masqdomains       sendmail.keepthisone

The file sendmail,v has been created to keep track of the changes and adds to the clutter. If we created an RCS directory first the record files would be automatically stored in that subdirectory.

Note that we have lost the working copy of sendmail.cf. To get it back we need to issue the command co (check out) which will extract and restore the last saved version. If we had set a lock with ci -l, the working copy would have remained available and other users would be prevented from checking out a copy.

All This might be o.k. if the sys admin is a one man band but it would be far preferable if this process were managed well away from our production environment.

In a networked environment I would always seek to have a host dedicated to the role of managing the other boxes be they production, development or test machines.

Replicate the directory tree of the working hosts from /usr/local/src, make our changes there and then distribute them as appropriate, to the test and production environments.

Even if we’re only managing a single host I would still contend that this is a good method of working that can save hours of work and heartache in the long run.

bash: cd: /usr/local/src/common/etc/mail: No such file or directory
sa101$ mkdir /usr/local/src/s common/etc/mail
sa101$ cd /usr/local/src/common/etc/mail
sa101$ cp /etc/mail/sendmail.cf .
sa101$ ci -l sendmail.cf
sendmail.cf,v  <--  sendmail.cf
enter description, terminated with single ’.’ or end of file:
NOTE: This is NOT the log message!
>> .
initial revision: 1.1
done
sa101$ vi sendmail.cf
skipping 18 old session files
reading sendmail.cf
 ........
wrote sendmail.cf, 1869 lines, 59668 chars
sa101$ ci -l
sendmail.cf,v  <--  sendmail.cf
new revision: 1.2; previous revision: 1.1
enter log message, terminated with single ’.’ or end of file:
>> .
done

Once satisfied that we have a working revision the updated copy can then be distributed to the test or production environment. This can be achieved with a simple copy or if we expect more frequent or complex updates, with the assistance of a make file.

22.1. RCS headers.

So that we know which version of a file we are using in our live environment the RCS process can update headers contained in the target file. In rcs identification strings are created by placing marker strings bracketed by the $ character. The marker string 1.2$Id:43rcs.ms,v on checkout will be replaced by a string with the format $Id: filename revision date time author state $

In addition to the 1.2$Id:43rcs.ms,v string it is useful to include the same data in a format more readily accessible to less experienced users e.g.

sa101$ cd /usr/local/src/common
sa101$ ls
etc header  usr var
sa101$ cat header
#$Id: 43rcs.ms,v 1.2 2013/09/12 13:37:07 fulford Exp fulford $
#$RCSfile: 43rcs.ms,v $
#$Source: /usr/local/src/caswallon-gw/usr/local/web/lts/linux/sa101/RCS/43rcs.ms,v $
#$Revision: 1.2 $
#$Date: 2013/09/12 13:37:07 $
#$Author: fulford $
# Copyright (c) 2013 C W Fulford. All rights reserved.
# For assistance call 0709 229 5385 or e-mail fulford@fulford.net
#################################################################

If we keep header in the stem of our source tree it can then be easily prepended to any script or configuration file we wish to use.

sa101$ cd /usr/local/src/common/etc
sa101$ cp ../header  auto.home
sa101$ vi auto.home
reading auto.home
 .......


sa101$ ci -l auto.home
RCS/auto.home,v  <--  auto.home
new revision: 1.2; previous revision: 1.1
enter log message, terminated with single ’.’ or end of file:
>> .
done
sa101$ cat auto.home
#$Id: 43rcs.ms,v 1.2 2013/09/12 13:37:07 fulford Exp fulford $
#$RCSfile: 43rcs.ms,v $
#$Source: /usr/local/src/caswallon-gw/usr/local/web/lts/linux/sa101/RCS/43rcs.ms,v $
#$Revision: 1.2 $
#$Date: 2013/09/12 13:37:07 $
#$Author: fulford $
# Copyright (c) 2013 C W Fulford. All rights reserved.
# For assistance call 0709 229 5385 or e-mail fulford@fulford.net
#################################################################
* :/u/&

It’s not as neat as sccs. I would like to be able to get rid of the keywords and the $ characters and have the target file name rather than the delta repository as one of the identifiers, but it does the job.

22.2. Alternatives.

Do a search on the internet and you will find many readily available alternatives which in many respects are far superior to RCS. Systems like Concurrent Version Control (cvs), Subversion (svn), BitKeeper and Linus Torvald’s git.

The problem from a systems administration view point is that these systems provide concurrent access, central repositories and automatic merging, all highly desirable in a substantial development project but features which should strike horror to heart of the sysadmin.

22.3. Exercises.

Check the man pages for rcsintro, rcs, ci, and co.

Use a search engine to find an introduction to subversion and the concurrent version system.

Find the objectives enumerated by Linus Torvald when designing git.


The layout and associated style sheets for this page are taken from the World Wide Web Consortium and used here under the W3C software licence.