fcopy(8)

πŸ“¦
version 6.6ubuntu1 Β· 2 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– 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 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. (lowest priority = it's the last one picked, bestie, not the loudest one πŸ’€)
  • -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 non-existing source directories. These warnings will not set the exit code to 1.
  • -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
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.

  • -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. (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).
  • -s source_dir β€” Look for SOURCE files relative to source_dir. Use $FAI/files if not specified.
  • -S β€” Enable variable substitution. Every occurrence of the pattern {%varname%} will be substituted by the value of the shell variable $varname which is mostly set in class/CLASSNAME.var. You can enable it for all calls of fcopy by setting the environment variable $FCOPY_SUBSTITUTE. Variable substitution is done before the execution of the preinst script.
  • -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

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 πŸ‘‘

ftar(8)

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. πŸ¦‹