xref: /netbsd/usr.bin/rdist/rdist.1 (revision c4a72b64)
1.\"	$NetBSD: rdist.1,v 1.15 2002/09/30 11:09:10 grant Exp $
2.\"
3.\" Copyright (c) 1985, 1990, 1993
4.\"	The Regents of the University of California.  All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. All advertising materials mentioning features or use of this software
15.\"    must display the following acknowledgement:
16.\"	This product includes software developed by the University of
17.\"	California, Berkeley and its contributors.
18.\" 4. Neither the name of the University nor the names of its contributors
19.\"    may be used to endorse or promote products derived from this software
20.\"    without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.\"	from: @(#)rdist.1	8.3 (Berkeley) 3/17/94
35.\"
36.Dd March 17, 1994
37.Dt RDIST 1
38.Os
39.Sh NAME
40.Nm rdist
41.Nd remote file distribution program
42.Sh SYNOPSIS
43.Nm
44.Op Fl nqbRhivwyD
45.Op Fl f Ar distfile
46.Op Fl d Ar var=value
47.Op Fl m Ar host
48.Op Ar name ...
49.Nm ""
50.Op Fl nqbRhivwyD
51.Fl c
52.Ar name ...
53.Oo login@ Oc Ns Ar host Ns Op :dest
54.Sh DESCRIPTION
55.Nm
56is a program to maintain identical copies of files over multiple hosts.
57It preserves the owner, group, mode, and mtime of files if possible and
58can update programs that are executing.
59.Nm
60reads commands from
61.Ar distfile
62to direct the updating of files and/or directories.
63.Pp
64Options specific to the first SYNOPSIS form:
65.Pp
66.Bl -tag -width indent
67.It Fl
68If
69.Ar distfile
70is
71.Sq Fl ,
72the standard input is used.
73.It Fl f Ar distfile
74Use the specified
75.Ar distfile .
76.El
77.Pp
78If either the
79.Fl f
80or
81.Sq Fl
82option is not specified, the program looks first for
83.Dq Pa distfile ,
84then
85.Dq Pa Distfile
86to use as the input.
87If no names are specified on the command line,
88.Nm
89will update all of the files and directories listed in
90.Ar distfile  .
91Otherwise, the argument is taken to be the name of a file to be updated
92or the label of a command to execute.
93If label and file names conflict, it is assumed to be a label.
94These may be used together to update specific files
95using specific commands.
96.Pp
97Options specific to the second SYNOPSIS form:
98.Pp
99.Bl -tag -width Fl
100.It Fl c
101Forces
102.Nm
103to interpret the remaining arguments as a small
104.Ar distfile  .
105.Pp
106The equivalent distfile is as follows.
107.Pp
108.Bd -filled -offset indent -compact
109.Pq Ar name ...
110.Li -\*[Gt]
111.Op Ar login@
112.Ar host
113.Bd -filled -offset indent -compact
114.Li install
115.Op Ar dest ;
116.Ed
117.Ed
118.El
119.Pp
120Options common to both forms:
121.Pp
122.Bl -tag -width Ic
123.It Fl b
124Binary comparison.
125Perform a binary comparison and update files if they differ
126rather than comparing dates and sizes.
127.It Fl d Ar var=value
128Define
129.Ar var
130to have
131.Ar value  .
132The
133.Fl d
134option is used to define or override variable definitions in the
135.Ar distfile  .
136.Ar Value
137can be the empty string, one name, or a list of names surrounded by
138parentheses and separated by tabs and/or spaces.
139.It Fl D
140Turn on debugging.
141.It Fl h
142Follow symbolic links.
143Copy the file that the link points to rather than the
144link itself.
145.It Fl i
146Ignore unresolved links.
147.Nm
148will normally try to maintain the link structure of files being transferred
149and warn the user if all the links cannot be found.
150.It Fl m Ar host
151Limit which machines are to be updated.
152Multiple
153.Fl m
154arguments can be given to limit updates to a subset of the hosts listed in the
155.Ar distfile  .
156.It Fl n
157Print the commands without executing them.
158This option is
159useful for debugging
160.Ar distfile  .
161.It Fl q
162Quiet mode.
163Files that are being modified are normally
164printed on standard output.
165The
166.Fl q
167option suppresses this.
168.It Fl R
169Remove extraneous files.
170If a directory is being updated, any files that exist
171on the remote host that do not exist in the master directory are removed.
172This is useful for maintaining truly identical copies of directories.
173.It Fl v
174Verify that the files are up to date on all the hosts.
175Any files
176that are out of date will be displayed but no files will be changed
177nor any mail sent.
178.It Fl w
179Whole mode.
180The whole file name is appended to the destination directory
181name.
182Normally, only the last component of a name is used when renaming files.
183This will preserve the directory structure of the files being
184copied instead of flattening the directory structure.
185For example,
186renaming a list of files such as ( dir1/f1 dir2/f2 ) to dir3 would create
187files dir3/dir1/f1 and dir3/dir2/f2 instead of dir3/f1 and dir3/f2.
188.It Fl y
189Younger mode.
190Files are normally updated if their
191.Ar mtime
192and
193.Ar size
194(see
195.Xr stat  2  )
196disagree.
197The
198.Fl y
199option causes
200.Nm
201not to update files that are younger than the master copy.
202This can be used
203to prevent newer copies on other hosts from being replaced.
204A warning message is printed for files which are newer than the master copy.
205.El
206.Pp
207.Ar Distfile
208contains a sequence of entries that specify the files
209to be copied, the destination hosts, and what operations to perform
210to do the updating.
211Each entry has one of the following formats.
212.Pp
213.Bd -literal -offset indent -compact
214\*[Lt]variable name\*[Gt] `=' \*[Lt]name list\*[Gt]
215[label:]\*[Lt]source list\*[Gt] `\-\*[Gt]' \*[Lt]destination list\*[Gt] \*[Lt]command list\*[Gt]
216[label:]\*[Lt]source list\*[Gt] `::' \*[Lt]time_stamp file\*[Gt] \*[Lt]command list\*[Gt]
217.Ed
218.Pp
219The first format is used for defining variables.
220The second format is used for distributing files to other hosts.
221The third format is used for making lists of files that have been changed
222since some given date.
223The
224.Ar source list
225specifies a
226list of files and/or directories on the local host which are to be used
227as the master copy for distribution.
228The
229.Ar destination list
230is the list of hosts to which these files are to be
231copied.
232Each file in the source list is added to a list of changes
233if the file is out of date on the host which is being updated (second format) or
234the file is newer than the time stamp file (third format).
235.Pp
236Labels are optional.
237They are used to identify a command for partial updates.
238.Pp
239Newlines, tabs, and blanks are only used as separators and are
240otherwise ignored.
241Comments begin with `#' and end with a newline.
242.Pp
243Variables to be expanded begin with `$' followed by one character or
244a name enclosed in curly braces (see the examples at the end).
245.Pp
246The source and destination lists have the following format:
247.Bd -literal -offset indent
248\*[Lt]name\*[Gt]
249.Ed
250or
251.Bd -literal -offset indent -compact
252`(' \*[Lt]zero or more names separated by white-space\*[Gt] `)'
253.Ed
254.Pp
255The shell meta-characters `[', `]', `{', `}', `*', and `?'
256are recognized and expanded (on the local host only) in the same way as
257.Xr csh  1  .
258They can be escaped with a backslash.
259The `~' character is also expanded in the same way as
260.Xr csh 1
261but is expanded separately on the local and destination hosts.
262When the
263.Fl w
264option is used with a file name that begins with `~', everything except the
265home directory is appended to the destination name.
266File names which do not begin with `/' or `~' use the destination user's
267home directory as the root directory for the rest of the file name.
268.Pp
269The command list consists of zero or more commands of the following
270format.
271.Bd -ragged -offset indent -compact
272.Bl -column except_patx pattern\ listx
273.It `install'	\*[Lt]options\*[Gt]	opt_dest_name `;'
274.It `notify'	\*[Lt]name list\*[Gt]	`;'
275.It `except'	\*[Lt]name list\*[Gt]	`;'
276.It `except_pat'	\*[Lt]pattern list\*[Gt]	`;'
277.It `special'	\*[Lt]name list\*[Gt]	string `;'
278.El
279.Ed
280.Pp
281The
282.Ic install
283command is used to copy out of date files and/or directories.
284Each source file is copied to each host in the destination list.
285Directories are recursively copied in the same way.
286.Ar Opt_dest_name
287is an optional parameter to rename files.
288If no
289.Ic install
290command appears in the command list or
291the destination name is not specified,
292the source file name is used.
293Directories in the path name will be created if they
294do not exist on the remote host.
295To help prevent disasters, a non-empty directory on a target host will
296never be replaced with a regular file or a symbolic link.
297However, under the `\-R' option a non-empty directory will be removed
298if the corresponding filename is completely absent on the master host.
299The
300.Ar options
301are `\-R', `\-h', `\-i', `\-v', `\-w', `\-y', and `\-b'
302and have the same semantics as
303options on the command line except they only apply to the files
304in the source list.
305The login name used on the destination host is the same as the local host
306unless the destination name is of the format ``login@host".
307.Pp
308The
309.Ic notify
310command is used to mail the list of files updated (and any errors
311that may have occurred) to the listed names.
312If no `@' appears in the name, the destination host is appended to
313the name
314(e.g., name1@host, name2@host, ...).
315.Pp
316The
317.Ic except
318command is used to update all of the files in the source list
319.Ic except
320for the files listed in
321.Ar name list  .
322This is usually used to copy everything in a directory except certain files.
323.Pp
324The
325.Ic except_pat
326command is like the
327.Ic except
328command except that
329.Ar pattern list
330is a list of regular expressions
331(see
332.Xr ed  1
333for details).
334If one of the patterns matches some string within a file name, that file will
335be ignored.
336Note that since `\e' is a quote character, it must be doubled to become
337part of the regular expression.
338Variables are expanded in
339.Ar pattern list
340but not shell file pattern matching characters.
341To include a `$', it
342must be escaped with `\e'.
343.Pp
344The
345.Ic special
346command is used to specify
347.Xr sh  1
348commands that are to be executed on the
349remote host after the file in
350.Ar name list
351is updated or installed.
352If the
353.Ar name list
354is omitted then the shell commands will be executed
355for every file updated or installed.
356The shell variable `FILE' is set
357to the current filename before executing the commands in
358.Ar string  .
359.Ar String
360starts and ends with `"' and can cross multiple lines in
361.Ar distfile .
362Multiple commands to the shell should be separated by `;'.
363Commands are executed in the user's home directory on the host
364being updated.
365The
366.Ar special
367command can be used to rebuild private databases, etc.
368after a program has been updated.
369.Pp
370The following is a small example:
371.Bd -literal -offset indent
372HOSTS = ( matisse root@arpa )
373
374FILES = ( /bin /lib /usr/bin /usr/games
375\t/usr/include/{*.h,{stand,sys,vax*,pascal,machine}/*.h}
376\t/usr/lib /usr/man/man? /usr/ucb /usr/local/rdist )
377
378EXLIB = ( Mail.rc aliases aliases.dir aliases.pag crontab dshrc
379\tsendmail.cf sendmail.fc sendmail.hf sendmail.st uucp vfont )
380
381${FILES} -\*[Gt] ${HOSTS}
382\tinstall -R ;
383\texcept /usr/lib/${EXLIB} ;
384\texcept /usr/games/lib ;
385\tspecial /usr/lib/sendmail "/usr/lib/sendmail -bz" ;
386
387srcs:
388/usr/src/bin -\*[Gt] arpa
389\texcept_pat ( \e\e.o\e$ /SCCS\e$ ) ;
390
391IMAGEN = (ips dviimp catdvi)
392
393imagen:
394/usr/local/${IMAGEN} -\*[Gt] arpa
395\tinstall /usr/local/lib ;
396\tnotify ralph ;
397
398${FILES} :: stamp.cory
399\tnotify root@cory ;
400.Ed
401.Sh FILES
402.Bl -tag -width /tmp/rdist* -compact
403.It Pa distfile
404input command file
405.It Pa /tmp/rdist*
406temporary file for update lists
407.El
408.Sh DIAGNOSTICS
409A complaint about mismatch of rdist version numbers may really stem
410from some problem with starting your shell, e.g., you are in too many groups.
411.Sh SEE ALSO
412.Xr csh 1 ,
413.Xr sh 1 ,
414.Xr stat 2
415.Sh HISTORY
416The
417.Nm
418command appeared in
419.Bx 4.3 .
420.Sh BUGS
421Source files must reside on the local host where
422.Nm
423is executed.
424.Pp
425There is no easy way to have a special command executed after all files
426in a directory have been updated.
427.Pp
428Variable expansion only works for name lists; there should be a general macro
429facility.
430.Pp
431.Nm
432aborts on files which have a negative mtime (before Jan 1, 1970).
433.Pp
434There should be a `force' option to allow replacement of non-empty directories
435by regular files or symlinks.
436A means of updating file modes and owners
437of otherwise identical files is also needed.
438