NAME

autolink - incremental rule+exception file-based management tool for unix


VERSION

Release 4.0 - 6/30/2001 SourceForge CVS $Id: autolink,v 1.1.1.1 2001/06/30 17:47:47 alex_aminoff Exp $


DESCRIPTION

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.

File Mapping and Directory Mapping

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.

Precedence of source locations

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.

Source file name extensions

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...}}

Hierarchy of source file name extensions

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:

  1. filename.hostname
  2. filename.host-category
  3. filename.ostype
  4. filename

Parts assembly

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.

Linking to a directory

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.

Reporting

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.


CONFIGURATION FILE SYNTAX

Hash marks at the beginning of a line are comment characters.

Configuration File Directives

assembly assembly-directory
sets the root of the tree where parts files are assembled.

directory-search target-dir search-dir ...
sets the path to be searched for executable binaries we might be overshadowing for targets in the specified target-dir. NOTE: all that will happen if such a case is found is an informational message will be printed, and even that will only happen if the debug level is > 0.

oss|operating-systems OSname ...
sets the list of recognized operating systems. NOTE: this will override any operating systems previously loaded in with custom perl code.

hosts hostname ...
sets the list of recognized hosts. NOTE: this will override any hosts previously specified in ``host'' configuration directives or loaded in with custom perl code.

hostcats host-category ...
sets the list of recognized host-categories. NOTE: this will override any host-categories previously specified in ``host'' configuration directives or loaded in with custom perl code.

host hostname host-category ...
specifies that the named host is a recognized host, the listed host categories are recognized host-categories, and that the named host is a member of the listed categories.

directory-map target-dir source-dir ...
sets up a mapping from one or more source directories to a particular target directory. The precedence of different source-dirs mapped to the same target-dir by the same directory-map statement is equal. The precedence of different source-dirs mapped to the same target-dir by different directory-map statements depends on the order of the directory-map statements in the config file.

httpd-test-prod-mutual-exclusion
a local hack, which enables excluding from linking sources of the form .../prod/root/.../httpd-test/ and .../test/root/.../httpd/, to support our prod 80 test 81 web server scheme

file-map target:source:newname:limitations:options
(for backwards compatibility, the directive ``file-map'' may be omitted).

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


AUTHOR

Alex Aminoff, alex_aminoff@alum.mit.edu


HISTORY

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.


TODO

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.