other versions
- jessie 4.3.1+deb8u1
- jessie-backports 5.3.6~bpo8+1
- stretch 5.3.6
- testing 5.8.1
- stretch-backports 5.8.2~bpo9+3
- unstable 5.8.3
other sections
fcopy(8) | System Manager's Manual | fcopy(8) |
NAME¶
fcopy - copy files using classesSYNOPSIS¶
fcopy [options] SOURCE...DESCRIPTION¶
Copy a file from SOURCE to its target using classes. It also sets permission modes, owner and group. Each SOURCE argument is a directory which contains one or more template files for the source file to copy. Depending on the list of defined classes, one file of the source directory is selected and copied to the target. The target filename is the name of the source directory. The exit code returned by fcopy is 0 if all files are copied successfully and >0 if an error occurs. For every successfully copied file, a log message is printed to standard output.OPTIONS¶
- Options -c, -s, -t and a SOURCE are required. Usually -c, -s and -t
- are set via variables in FAI.
- -B
- Remove backup files with suffix .pre_fcopy. You can also set the environment variable FCOPY_NOBACKUP to 1.
- -b dir
- Don't copy files to file.pre_fcopy, but use hierarchy under "dir" instead. The same effect is achieved by setting environment variable FAI_BACKUPDIR.
- -c class[,class]
- Define classes. Multiple classes must be comma separated. If not specified, use the shell environment variable $classes (space separated). The first class has lowest priority.
- -C file
- Read classes from file. Lines can contain multiple classes which are space separated. Lines starting with # are comments.
- -d
- Delete target file if no class applies.
- -D
- Create debugging output.
- -F file
- Read list of sources from file. One SOURCE per line.
- -h
- Show help, version and summary of options.
- -H
- If source is a symbolic link, make destination a symbolic link too.
- -i
- Ignore warnings about no matching class and always exit with 0.
- -I dir[,dir]
- Override list of ignored directories when recursing. If not given, it is taken from $FCOPY_IGNOREDIRS and as a last chance an internal list of known revision control system's metadata is used (CVS, .cvs, {arch}, .arch-ids).
- -l
- Do not copy if destination is a symbolic link
- -L file
- Log SOURCE and used class to file. Output format is
- -m user,group,mode
- Set user, group and mode for all copied files (mode as octal number, user and group numeric id or name). If not specified, use file file-modes or data of source file.
- -M
- Use default values for user, group and mode. This is equal to -m root,root,0644
- -n
- Print the commands, but do not execute them. This is like --dry-run in other programs. You can enable it for all calls of fcopy by setting the environment variable $FCOPY_DRYRUN.
- -r
- Copy recursively (traverse down the tree). Copy all files below SOURCE. These are all subdirectory leaves in the SOURCE tree. Ignore "ignored" directories (see "-I" for details).
- -s source_dir
- Look for SOURCE files relative to source_dir. Use $FAI/files if not specified.
- -t target_dir
- Copy files relative to target_dir. Use $FAI_ROOT if not specified.
- -U
- If in softupdate mode skip this entire fcopy command.
- -v
- Create verbose output.
SCRIPTS¶
- preinst
- If a file 'preinst' exists and is executable, it is used in the following way:
- 1.
- a temporary copy of the file for the used class is created
- 2.
- preinst is called with the used class and the full pathname to this temporary copy (you can do in-place substitutions or other modifications on this copy)
- 3.
- the copy is compared to the destination and replaces it only if there are any differences and if the preinst scripts has a exit code zero.
- postinst
- If a file 'postinst' exists and is executable, it is called after successfully having copied the file. It is called with two parameters, the class being used and the full pathname to the target file. The variable ROOTCMD is set, so you can prepend it to commands which should be executed in the newly installed system.
EXAMPLES¶
Suppose the source directory /files/etc/X11/xorg.conf consists of the following files: CAD DEFAULT LAB MACH64 server1 ant04 postinst Each file is an instance of a xorg.conf file for a different Xserver configuration. The command# fcopy -s /files -t /target /etc/X11/xorg.conf copies one of these files from the directory /files/etc/X11/xorg.conf to the file /target/etc/xorg.conf. For all defined classes, fcopy looks if a corresponding file exists. The class with the highest priority that matches an existing file name will be used for copying. Here are examples of defined classes for different hosts and the file which will be copied by fcopy.
- Host belongs to the classes
- File used for copy
- DEFAULT,LAB,server3
- LAB
- DEFAULT,CAD,server1
- server1
- DEFAULT,MACH64,ant01
- MACH64
- DEFAULT,TFT,ant13
- DEFAULT server1
NOTES¶
Do not create a file DEFAULT if no reasonable default configuration file can be used. It's better to exit with an error than to copy a wrong configuration file. This command can also be used to maintain your configuration files on a huge number of hosts.SEE ALSO¶
ftar(8)AUTHOR¶
Thomas Lange <lange@informatik.uni-koeln.de>18 November 2014 | FAI 4 |