autolink - incremental rule+exception file-based management tool for unix
Release 4.0 - 6/30/2001 SourceForge CVS $Id: autolink,v 1.1.1.1 2001/06/30 17:47:47 alex_aminoff Exp $
The autolink script controls files (e.g. configuration files such as inetd.conf or http.conf) by copying from or creating a symlink to a canonical version. autolink can choose which canonical version to use on a file by file basis. autolink can also assemble files by concatenating together sub-parts (e.g. VirtualHost directives for several different web sites on the same machine).
autolink is designed to help administer a group of unix machines with different OSs and uses. Typically, one would transmit a directory tree containing canonical versions of certain files to each machine across a network, by NFS or rdist/``1'' or scp/``1''. Other ``source'' directory trees may exist on some or all of the machines, one for each project perhaps, or one for each user. autolink will scan all these directories, creating links or copying, subject to rules described below.
The simplest way to tell autolink that a certain file should be linked
or copied is with a file-map
directive in the configuration file. This
causes autolink to create the link specified: equivalent to a simple
ln -s command.
More commonly, autolink can map entire source trees to target trees. Typically the source trees will be very sparse: only targets for which sources exist will be touched by autolink. Many source trees can be configured for each target tree. This is a powerful feature, because the source trees have precedence according to the order they are listed in the configuration file.
If several sources for a given target file are found in different
source trees, autolink will use the one with highest precedence:
First, it will use any explicit file-map
statement for this specific
target file. Then, it will use the first directory-map
statement
covering this target, then the second, etc. If more than one source
is found at the same level of precedence, a loud error message is
displayed.
File name extensions can be used to specify that a given version of a source file applies to a certain category of machines: either a particular host specified by name, a particular OS, or a custom-defined host-category.
The complete syntax for a source file name is:
filename{.dirlink|.part{N}}{.copy}{.ostype/hostname/hostcat{.ostype/hostname/hostcat...}}
Specifying a hostname, OS, or configured host-category limits the link to being created only on a machine matching the extension. In cases where multiple potential sources exist in the same directory, the most specific will be preferred:
If any of the potential valid links have a .part*
extension, then
instead of creating a link directly to the file, autolink will
concatenate all valid .part
files into /var/assembly, and create the
link to the assembled file. Part files may have a number attached
indicating the order in which they are to be concatenated. If multiple
parts files with the same specified number are found, only one is
incorporated, resolved the same way multiple sources for a given target
are resolved.
When looking for source files, directories are always descended,
unless they are named with a .dirlink
extension, in which case a link
is created to the directory rather than its children.
To find out what is being linked to where, you can run autolink in reporting mode, using the -reporton switch. The report includes a header with an explanation of how to read the report. Typically you would run a report with the -a switch in order to see all files controlled by autolink, but you can also specify a particular target file or directory.
Hash marks at the beginning of a line are comment characters.
The I<target> field is required. This specifies what configuration file or binary the configuration line affects.
The I<source> field specifies where the link will point to. If left blank, this field will be autodetected using the standard algorithm described above. For backwards compatibility, the special reserved word "ignore" in this field says to not make a link to the specified target even if a source file would otherwise be found.
The newname field specified what the target file that is being replaced should be renamed to. This can be a relative or absolute pathname. Blank gives the default: filename.old in the same directory.
The limitations field is a list of machines or OSs for which this entry applies. Blank means it applies universally.
options:
ignore
- says to not make a link to the specified target even if a
source file would otherwise be found.
copy
- instead of linking to the file, copy it into place
Alex Aminoff, alex_aminoff@alum.mit.edu
Versions 1,2, and 3 were developed while I was working at the Harvard University Library Office for Information Systems, around 1995-97. Version 2 was current when I wrote the white paper for the Systems Management conference. Version 3 was the first one I put up for general download and use, with minimal publicity. Version 4, done in 2001, involved mostly redoing the documentation in perlpod format for publication to SourceForge.
Add a ``generate'' mode, where rather than linking or copying the ``source'' is taken to be an executable file, which spits out the target file on its stdout. This makes a lot of sense as an option to a file-map directive. You could do it as an extension right in the source tree too, but then what do you do with any other sources found?? Feed the path names as arguments to the generator perhaps?
In principle, the options to the file-map directive should be exactly the same as the possible special filename extensions, and processed in the same way. Right now that is not the case.