1.\" Copyright (c) 1985, 1990, 1993 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" %sccs.include.redist.roff% 5.\" 6.\" @(#)rdist.1 8.3 (Berkeley) 03/17/94 7.\" 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 Ar host 20.Op Ar name ... 21.Nm rdist 22.Op Fl nqbRhivwy 23.Fl c 24.Ar name ... 25.Oo login@ Oc Ns Ar host Ns Op :dest 26.Sh DESCRIPTION 27.Nm Rdist 28is a program to maintain identical copies of files over multiple hosts. 29It preserves the owner, group, mode, and mtime of files if possible and 30can update programs that are executing. 31.Nm Rdist 32reads commands from 33.Ar distfile 34to direct the updating of files and/or directories. 35.Pp 36Options specific to the first SYNOPSIS form: 37.Pp 38.Bl -tag -width indent 39.It Fl 40If 41.Ar distfile 42is 43.Sq Fl , 44the standard input is used. 45.It Fl f Ar distfile 46Use the specified 47.Ar distfile. 48.El 49.Pp 50If either the 51.Fl f 52or 53.Sq Fl 54option is not specified, the program looks first for 55.Dq Pa distfile , 56then 57.Dq Pa Distfile 58to use as the input. 59If no names are specified on the command line, 60.Nm rdist 61will update all of the files and directories listed in 62.Ar distfile . 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. 68.Pp 69Options specific to the second SYNOPSIS form: 70.Pp 71.Bl -tag -width Fl c 72.It Fl c 73Forces 74.Nm rdist 75to interpret the remaining arguments as a small 76.Ar distfile . 77.Pp 78The equivalent distfile is as follows. 79.Pp 80.Bd -filled -offset indent -compact 81.Pq Ar name ... 82.Li -> 83.Op Ar login@ 84.Ar host 85.Bd -filled -offset indent -compact 86.Li install 87.Op Ar dest ; 88.Ed 89.Ed 90.El 91.Pp 92Options common to both forms: 93.Pp 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 99Define 100.Ar var 101to have 102.Ar value . 103The 104.Fl d 105option is used to define or override variable definitions in the 106.Ar distfile . 107.Ar Value 108can be the empty string, one name, or a list of names surrounded by 109parentheses and separated by tabs and/or spaces. 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 transferred 117and warn the user if all the links cannot be found. 118.It Fl m Ar host 119Limit which machines are to be updated. Multiple 120.Fl m 121arguments can be given to limit updates to a subset of the hosts listed in the 122.Ar distfile . 123.It Fl n 124Print the commands without executing them. This option is 125useful for debugging 126.Ar distfile . 127.It Fl q 128Quiet mode. Files that are being modified are normally 129printed on standard output. The 130.Fl q 131option suppresses this. 132.It Fl R 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 truly identical copies of directories. 136.It Fl v 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. 140.It Fl w 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. 147.It Fl y 148Younger mode. Files are normally updated if their 149.Ar mtime 150and 151.Ar size 152(see 153.Xr stat 2 ) 154disagree. The 155.Fl y 156option causes 157.Nm rdist 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. 162.El 163.Pp 164.Ar Distfile 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. 168.Pp 169.Bd -literal -offset indent -compact 170<variable name> `=' <name list> 171[label:]<source list> `\->' <destination list> <command list> 172[label:]<source list> `::' <time_stamp file> <command list> 173.Ed 174.Pp 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. 179The 180.Ar source list 181specifies a 182list of files and/or directories on the local host which are to be used 183as the master copy for distribution. 184The 185.Ar destination list 186is the list of hosts to which these files are to be 187copied. Each file in the source list is added to a list of changes 188if the file is out of date on the host which is being updated (second format) or 189the file is newer than the time stamp file (third format). 190.Pp 191Labels are optional. They are used to identify a command for partial updates. 192.Pp 193Newlines, tabs, and blanks are only used as separators and are 194otherwise ignored. Comments begin with `#' and end with a newline. 195.Pp 196Variables to be expanded begin with `$' followed by one character or 197a name enclosed in curly braces (see the examples at the end). 198.Pp 199The source and destination lists have the following format: 200.Bd -literal -offset indent 201<name> 202.Ed 203or 204.Bd -literal -offset indent -compact 205`(' <zero or more names separated by white-space> `)' 206.Ed 207.Pp 208The shell meta-characters `[', `]', `{', `}', `*', and `?' 209are recognized and expanded (on the local host only) in the same way as 210.Xr csh 1 . 211They can be escaped with a backslash. 212The `~' character is also expanded in the same way as 213.Xr csh 1 214but is expanded separately on the local and destination hosts. 215When the 216.Fl w 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. 221.Pp 222The command list consists of zero or more commands of the following 223format. 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 233.Pp 234The 235.Ic install 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. 239.Ar Opt_dest_name 240is an optional parameter to rename files. 241If no 242.Ic install 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. 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. 252The 253.Ar options 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". 260.Pp 261The 262.Ic notify 263command is used to mail the list of files updated (and any errors 264that may have occurred) 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, ...). 268.Pp 269The 270.Ic except 271command is used to update all of the files in the source list 272.Ic except 273for the files listed in 274.Ar name list . 275This is usually used to copy everything in a directory except certain files. 276.Pp 277The 278.Ic except_pat 279command is like the 280.Ic except 281command except that 282.Ar pattern list 283is a list of regular expressions 284(see 285.Xr ed 1 286for details). 287If one of the patterns matches some string within a file name, that file will 288be ignored. 289Note that since `\e' is a quote character, it must be doubled to become 290part of the regular expression. Variables are expanded in 291.Ar pattern list 292but not shell file pattern matching characters. To include a `$', it 293must be escaped with `\e'. 294.Pp 295The 296.Ic special 297command is used to specify 298.Xr sh 1 299commands that are to be executed on the 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 306for every file updated or installed. The shell variable `FILE' is set 307to the current filename before executing the commands in 308.Ar string . 309.Ar String 310starts and ends with `"' and can cross multiple lines in 311.Ar distfile . 312Multiple commands to the shell should be separated by `;'. 313Commands are executed in the user's home directory on the host 314being updated. 315The 316.Ar special 317command can be used to rebuild private databases, etc. 318after a program has been updated. 319.Pp 320The following is a small example: 321.Bd -literal -offset indent 322HOSTS = ( matisse root@arpa ) 323 324FILES = ( /bin /lib /usr/bin /usr/games 325\t/usr/include/{*.h,{stand,sys,vax*,pascal,machine}/*.h} 326\t/usr/lib /usr/man/man? /usr/ucb /usr/local/rdist ) 327 328EXLIB = ( Mail.rc aliases aliases.dir aliases.pag crontab dshrc 329\tsendmail.cf sendmail.fc sendmail.hf sendmail.st uucp vfont ) 330 331${FILES} -> ${HOSTS} 332\tinstall -R ; 333\texcept /usr/lib/${EXLIB} ; 334\texcept /usr/games/lib ; 335\tspecial /usr/lib/sendmail "/usr/lib/sendmail -bz" ; 336 337srcs: 338/usr/src/bin -> arpa 339\texcept_pat ( \e\e.o\e$ /SCCS\e$ ) ; 340 341IMAGEN = (ips dviimp catdvi) 342 343imagen: 344/usr/local/${IMAGEN} -> arpa 345\tinstall /usr/local/lib ; 346\tnotify ralph ; 347 348${FILES} :: stamp.cory 349\tnotify root@cory ; 350.Ed 351.Sh FILES 352.Bl -tag -width /tmp/rdist* -compact 353.It Pa distfile 354input command file 355.It Pa /tmp/rdist* 356temporary file for update lists 357.El 358.Sh SEE ALSO 359.Xr sh 1 , 360.Xr csh 1 , 361.Xr stat 2 362.Sh HISTORY 363The 364.Nm rdist 365command appeared in 366.Bx 4.3 . 367.Sh DIAGNOSTICS 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. 370.Sh BUGS 371Source files must reside on the local host where 372.Nm rdist 373is executed. 374.Pp 375There is no easy way to have a special command executed after all files 376in a directory have been updated. 377.Pp 378Variable expansion only works for name lists; there should be a general macro 379facility. 380.Pp 381.Nm Rdist 382aborts on files which have a negative mtime (before Jan 1, 1970). 383.Pp 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. 387