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