fcopy(8)
π fcopy(8) β the "copy files using classes" glow-up π
okay so bestie, welcome to fcopy from the System Manager's Manual. This is the tool that copies your config files around using classes, and honestly? It's giving main character energy. Let's get into it. π¦
β¨ NAME β¨
fcopy β copy files using classes
πΈ SYNOPSIS πΈ
fcopy [options] SOURCE...
π DESCRIPTION π
Copy a file from SOURCE to its target using classes. It also sets permission modes for owner and group. Periodt.
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. Not me being transparent about my exit codes, we love an honest icon. π
π 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 variableFCOPY_NOBACKUPto1.-bdir β Don't copy files tofile.pre_fcopy, but use hierarchy under "dir" instead. The same effect is achieved by setting environment variableFAI_BACKUPDIR.-cclass[,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. (lowest priority = it's the last one picked, bestie, not the loudest one π)-Cfile β 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.-Ffile β 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 non-existing source directories. These warnings will not set the exit code to1.-Idir[,dir] β Override list of ignored directories when recursing. If not given, it is taken from$FCOPY_IGNOREDIRSand 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.-Lfile β Log SOURCE and used class to file. Output format is
SOURCE CLASS COMMENT
where COMMENT gives some information about why the file has been preserved. If not specified and $LOGDIR is set, use $LOGDIR/fcopy.log.
-muser,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 filefile-modesor 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-runin other programs. You can enable it for all calls offcopyby setting the environment variable$FCOPY_DRYRUN. (rehearsal mode, bestie β manifesting the copy without actually doing it β¨)-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).-ssource_dir β Look for SOURCE files relative to source_dir. Use$FAI/filesif not specified.-Sβ Enable variable substitution. Every occurrence of the pattern{%varname%}will be substituted by the value of the shell variable$varnamewhich is mostly set inclass/CLASSNAME.var. You can enable it for all calls offcopyby setting the environment variable$FCOPY_SUBSTITUTE. Variable substitution is done before the execution of thepreinstscript.-ttarget_dir β Copy files relative to target_dir. Use$FAI_ROOTif not specified.-Uβ If in softupdate mode skip this entirefcopycommand.-vβ Create verbose output.
π§ SCRIPTS π§
preinst
If a file preinst exists and is executable, it is used in the following way:
- a temporary copy of the file for the used class is created
preinstis 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)- the copy is compared to the destination and replaces it only if there are any differences and if the
preinstscripts 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
In FAI the list of defined classes starts with DEFAULT and the last class is the hostname. DEFAULT is only used when no file for another class exists. If a file is equal to the hostname, this will be used, since hostname should always be the last class.
User, group and permissions for the files can be defined in several ways. The file file-modes in the source directory has the highest priority, followed by modes specified by -m/-M. If neither applies, the modes from the source file are used.
The file file-modes in the source directory can contain one line for each class. The space separated parameters are:
owner group mode class
Where owner and group can be specified by numeric id or by name. The file permissions are defined by mode, which must be octal. If class is missing, the data is used for all other classes, for which no data is defined. If neither -m or file-modes data is available, the user, group and mode of the source file will be used for the target file.
Missing subdirectories for the target file are created with mode 0755. If the destination file already exists and is different from the source file, the suffix .pre_fcopy is appended to the old version of the target file. If source and target files are equal, no copy is performed. A copied file gets the same access and modification time as the source file, not the time of the copy. If the file postinst exists, it will be executed after the file was copied.
π₯ 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. (fr fr, do NOT do this one, it's giving chaos π)
This command can also be used to maintain your configuration files on a huge number of hosts. she's versatile, she contains multitudes π
π SEE ALSO π
This program is part of FAI (Fully Automatic Installation). See the FAI manual for more information on how to use fcopy. The FAI homepage is https://fai-project.org.
π AUTHOR π
Thomas Lange <lange@cs.uni-koeln.de> Henning Glawe <glaweh@physik.fu-berlin.de>
And that's the whole page, bestie β this one's from FAI 5.8, dated 8 February 2019, and it ate. π β¨ Go copy some files. π¦
π¦ where this page comes from
- debian bookworm: fai-client 6.0.3+deb12u1 Β· GPL-2.0-or-later
- debian trixie: fai-client 6.4.3 Β· GPL-2.0-or-later
- ubuntu noble: fai-client 6.0.5ubuntu1 Β· GPL-2.0-or-later
- ubuntu resolute: fai-client 6.4.3ubuntu1 Β· GPL-2.0-or-later
- ubuntu stonking: fai-client 6.6ubuntu1 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms