Re: Versioned /etc ?
On 2007-04-25 @ 20:51:26 (week 17) Jeronimo Pellegrini wrote:
> Hi.
>
> So, I was trying to figure out a way to get automatic versioning
> for all files in /etc, and I wonder if someone tried that already.
<snip \>
> Does anyone have other ideas?
Hi Jeronimo,
There's another option you might consider. I've been thinking about the
same thing, but after experimenting with several tools (RCS, CVS,
changetrack, etc.) I decided they were either too cumbersome to use, or
too "heavy" for the simple needs I had. So I decided to write a script
that did what I wanted.
If your purpose is to just keep versioned copies of the files you have changed
yourself, then why not use a wrapper for your editor that makes a datestamped
copy of the file you want to edit before it is opened? If you're interested I
can send you the script. Just let me know.
Don't let the name vicf put you off, you can use any editor you want. I just
called it vicf, because visudo gave me the idea and I happen to be a complete
vim addict.
Grx HdV
P.S. Here's the accompanying manpage, so you can decide if this script fits
your needs:
$vicf --manual
VICF(1) User Contributed Perl Documentation VICF(1)
NAME
vicf - edit a configuration file and keep a dated copy of the original.
SYNOPSIS
vicf [options] <argument>
List of options:
[-h|--help|-?] [--manual] [-V|--version] [-r|--root <directory>]
[-d|--datetime <format>] [-n|--sequencenr <format>]
[-a|--append_sequencenr] [-p|--permissions] [-o|--owner] [-g|--group]
[-t|--times] [-b|--backup] [-x|--x_editor]
OPTIONS
--help
Print a brief help message.
--manual
Print the full manual.
--version
Print version and copyright information.
--root
The directory under which a dated copy of the original file should
be stored.
--datetime
A format string suitable for strftime(). Together with the local
time this parameter will used as input for strftime(). The result
will be appended to the name of the target file. See man 3 strftime
for more details.
--sequencenr
A format string suitable for sprintf(). This will be used to gener-
ate a sequence number, which will be append to the filename if the
target file already exists.
--append_sequencenr
Append a sequence number to the filename, even if it does not
exist. Used to start sequences at 1 instead of 2.
--permissions
Preserve the access permissions of the original file.
--owner
Preserve the owner of the original file.
--group
Preserve the group of the original file.
--times
Preserve the access and modification times of the original file.
--backup
Instruct the editor to make a backup of the original file. This is
a convenience option that has nothing to do with the dated copy of
the original file.
--x_editor
Start the editor in graphical mode instead of console mode.
At the top of the code there is a section named 'User-definable
defaults' where defaults appropriate for the current environment can be
set. Doing so alleviates the need to specify options on every invoca-
tion of the program.
ARGUMENTS
This program accepts only one argument, which is the path to the file
to be edited.
DESCRIPTION
This program makes versioned copies of the files you edit. It is useful
for everyone who wants to have a history of changes made to their
files, but doesn't want to run a CVS, SubVersion or equivalent server
just for that purpose. A copy of the original file is stored in a
repository, the root directory, using the full path of the original
file. A timestamp and optionally a sequence number is appended to the
file's name to make sure it is unique. After that the file is opened
with the preferred editor to be edited, just like usual.
NOTES/TODO
Somehow the access time of the original is not always preserved in the
copy. Need to find out what is causing this. In those cases where this
happens the atime given to utime() seems to be correct.
PREREQUISITES
- Perl 5.005 or later
BUGS
There are bound to be some. Let me know if you find one (or more...).
AUTHOR
J.A. de Vries <hdv@jadev.org>
Current contact information and the master copy of this program can be
found at http://www.jadev.org
OPYRIGHT
Copyright (C) 2007 Jadev
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 2 of the License, 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 MER-
CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License for more details.
You can find a copy of the GNU General Public License at
http://www.gnu.org/licenses/gpl.html
perl v5.8.8 2007-03-19 VICF(1)
Reply to: