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