Ilya Evseev

Table of Contents

chconf - Manage multiple system configuration profiles


chconf — Manage multiple system configuration profiles


chconf <profile-name>

chconf --init <profile-name>

chconf --list [<profile-name>]


Chconf is a trivial utility that allows you switch easily between multiple system-wide software/hardware/network configurations.

The main idea is that every configuration, or profile, may be described by set of files, and restoring of configuration may be performed by restoring of these files with a lot of additional commands, like "service bind reload".

Managing profiles

Every profile is descripbed by single text file described below in "Profile control file" section. Chconf provides four operations on them:

  • creation,
  • activating,
  • listing contents of selected profile,
  • listing names of all profiles.

Creation profile

When you run "chconf --init <profile-name>", Chconf reads filenames from profile description file (by default this is /etc/chconf.d/profile-name.init), then copies appropriated files from its location to profile backup directory, by default /etc/chconf.d/profile-name.

This should be performed on profile installation, or when you want to update files stored in profile backup directory by actual contents of currently used configuration.

Activating profile

Running "chconf <profile-name>" causes reading of profile configuration file and performing all commands: copying/symlinking from backup directory to system-wide location, erasing, running custom commands, etc.

Listing profiles

Running "chconf --list" displays all possible profiles, initialized or not. Running "chconf --list <profile-name>" displays all files currently stored in backup directory of selected profile.

Profile control file

Each line in profile control file has following format:

<ACTION> <args...>

Shell patterns, extended patterns (enabled by shopt -s extglob) and meta-characters in action arguments are supported normally. For example, $USER will be translated to root, and "*.rpmsave" or "sysconfig/network-scripts/ifcfg-eth+([0-9:])" will be expanded to all found filenames matching this wildcard.

All paths and filenames are relative to system configuration directory (by default, /etc) or to profile backup directory, even if they beginning from “/”.

All commands and file operations are performed in reading order.

All file opertions are forced. This means that files are overwritten or removed without prompting.


Empty lines, or lines started from "#" character are ignored.


Aliases: f, file.

Copy files matching wildcard from backup directory to system configuration directory.

Files are initially stored to backup directory when you run chconf with --init option.

Remember that you should manually update backup files, if original configuration is changed when this profile is active.


Aliases: l, s, symlink.

Create symbolic links in system configuration directory pointing to files stored in profile backup directory.

Symbolic links instead of copying have three reasons.

First, all changes applied to system configs are transparently stored in profile backup. So, you don't need to refresh profile backup manually.

Second, symbolic link indicates that appropriate file is managed by Chconf.

Third, configuration file is presented in single instance, and this saves disk space!;-)

Symlinking may be incompatible with some software that requires regular files only, i.e., detects file not only by filename, but also by filetype.


Aliases: h, hlink, hard.

Create hardlinks in system configuration directory pointing to files stored in profile backup directory.

This gives you all preferences of symlinking, except evident Chconf indicating, plus full compatibility with all software that detects file by filetype additionally to filename.


Aliases: rm, del, delete, erase.

All files matching wildcard are removed.


Aliases: action, a, do, exec, execute, cmd, command.

Execute given command.


#   /etc/chconf.d/network.template  --  profile control file for chconf.
#   Skeleton for switching between multiple network policies.
#   How to use?
#      1) Put this file to /etc/chconf.d directory
#      2) Create all needed profiles like following:
#         bash> chconf --make-from network home office gprs
#      3) Initialize profiles by data:
#         bash> for p in home office gprs; do chconf --init $p; done
#      4) Edit profile files in /etc/chconf.d/{home,office,gprs}/
#      5) Use "chconf profile-name" for activating.

service network stop

# Network address and gateway
del  sysconfig/network-scripts/ifcfg-eth+([0-9:])
copy sysconfig/network-scripts/ifcfg-eth+([0-9:])
copy sysconfig/network

# DNS resolving
copy hosts
copy resolv.conf
exec update_chrooted conf
service postfix reload
service bind reload

# Proxy server
copy profile.d/proxy.*

# Packet filter
copy sysconfig/iptables
service iptables reload

service network start

## EOF ##


/sbin/chconf -- the main script.

/etc/chconf.d -- base directory for profile control files and profile backup directories.

/etc/chconf.d/<profile-name>.init -- control file for <profile-name>.

/etc/chconf.d/<profile-name>.init -- backup directory for <profile-name>.

Хостинг от uCoz