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