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