CT320: Network and System Administration

Fall 2019

Config

Show Lecture.Config as a slide show.

CT320 Config

Smash Cut

blix

Consider the blix command (I made it up), which blixes things. It requires configuration information.

A configuration file

The straightforward solution is to have a configuration file, /etc/blix.conf. It’s installed as part of the blix package, and contains default values, such as:

    Frequency: 30m		# Every 30 minutes
    Priority: medium
    Level: 3			# 1 is lowest level, 5 is highest level
    Users: root			# Only root is permitted to blix

To allow user sanchez to blix, change the last line to:

    Users: root,sanchez		# Sanchez, too!

Problem

What happens when a new revision of the blix package comes out? A new parameter has been added to /etc/blix.conf. However, you’ve edited /etc/blix.conf:

Old New
    Frequency: 30m
    Priority: medium
    Level: 3
    Users: root,sanchez
    Frequency: 30m
    Priority: medium
    Level: 3
    Users: root
    Compression: xz

Conflict! When you update, you’ll have to merge that file manually. Ack!

Solution #1

You could have separate system & user config files:

/etc/blix.system.conf would be reserved for the system defaults, and /etc/blix.user.conf would be available for user editing.

That sounds great, but …

Problem

What if another package wants to add some blixing information? Say that the vim package wants to add a line to the blix configuration file to specify how often ~/.vimrc should be blixed?

Whichever file it modifies, we’ll have the same old problem at the next update.

What are we supposed to do—have an unlimited number of configuration files!?

An Unlimited Number of Configuration Files

(That’s a smash cut, you see.)

Instead of a single configuration file /etc/blix.conf, or just a few config files, have a directory /etc/blix.d.

The blix program will treat all files in /etc/blix.d as configuration file.

Forcing Order

If the order matters, we can add prefixes to the filenames to force processing order:

The filenames will be unique, as long as two packages don’t use the same name.

It’s Popular

$ ls -ld /etc/*.d
drwxr-xr-x.  2 root root    4096 Dec  5  2019 /etc/ant.d
drwxr-xr-x.  2 root root    4096 Oct 14  2023 /etc/auto.master.d
drwxr-xr-x.  2 root root    4096 Apr 12 11:42 /etc/bash_completion.d
drwxr-xr-x.  2 root root    4096 Oct 15  2023 /etc/binfmt.d
drwxr-xr-x.  2 root root    4096 Oct 14  2023 /etc/chkconfig.d
drwxr-xr-x.  2 root root    4096 Mar  6 09:37 /etc/cron.d
drwxr-xr-x.  2 root root    4096 Dec 19 09:30 /etc/depmod.d
drwxr-xr-x.  2 root dnsmasq 4096 Mar 14 14:05 /etc/dnsmasq.d
drwxr-xr-x.  2 root root    4096 Oct 14  2023 /etc/dracut.conf.d
drwxr-xr-x.  2 root root    4096 Mar 31  2023 /etc/exports.d
drwxr-xr-x.  2 root root    4096 Apr 12 11:41 /etc/gdbinit.d
drwx------.  2 root root    4096 Apr 12 11:42 /etc/grub.d
lrwxrwxrwx   1 root root      11 Oct 14  2023 /etc/init.d -> rc.d/init.d
drwx------.  3 root root    4096 Oct 11  2023 /etc/ipsec.d
drwxr-xr-x.  2 root root    4096 Sep  7  2021 /etc/issue.d
drwxr-xr-x.  2 root root    4096 Nov 15 00:47 /etc/krb5.conf.d
drwxr-xr-x.  2 root root    4096 Apr 12 12:33 /etc/ld.so.conf.d
drwxr-xr-x.  2 root root    4096 Dec 19 09:24 /etc/libibverbs.d
drwxr-xr-x.  2 root root    4096 Oct 12  2019 /etc/libpaper.d
drwxr-xr-x.  2 root root    4096 Nov 23 01:15 /etc/logrotate.d
drwxr-xr-x.  2 root root    4096 Sep  7  2021 /etc/lsb-release.d
drwxr-xr-x   3 root root    4096 Apr 18  2022 /etc/mdevctl.d
drwxr-xr-x.  2 root root    4096 Oct 14  2023 /etc/modprobe.d
drwxr-xr-x.  2 root root    4096 Oct 15  2023 /etc/modules-load.d
drwxr-xr-x.  2 root root    4096 Oct 14  2023 /etc/motd.d
drwxr-xr-x.  2 root root    4096 Sep  7  2021 /etc/my.cnf.d
drwxr-xr-x.  2 root root    4096 Apr  1  2023 /etc/oddjobd.conf.d
drwxr-xr-x.  2 root root    4096 Dec 19 09:52 /etc/pam.d
drwxr-xr-x.  2 root root    4096 Jan  4  2022 /etc/php.d
drwxr-xr-x.  2 root root    4096 Sep  7  2021 /etc/php-fpm.d
drwxr-xr-x.  2 root root    4096 Apr 28  2023 /etc/popt.d
drwxr-xr-x.  2 root root    4096 Apr 12 11:41 /etc/prelink.conf.d
drwxr-xr-x.  2 root root    4096 Apr 12 11:42 /etc/profile.d
lrwxrwxrwx   1 root root      10 Oct 14  2023 /etc/rc0.d -> rc.d/rc0.d
lrwxrwxrwx   1 root root      10 Oct 14  2023 /etc/rc1.d -> rc.d/rc1.d
lrwxrwxrwx   1 root root      10 Oct 14  2023 /etc/rc2.d -> rc.d/rc2.d
lrwxrwxrwx   1 root root      10 Oct 14  2023 /etc/rc3.d -> rc.d/rc3.d
lrwxrwxrwx   1 root root      10 Oct 14  2023 /etc/rc4.d -> rc.d/rc4.d
lrwxrwxrwx   1 root root      10 Oct 14  2023 /etc/rc5.d -> rc.d/rc5.d
lrwxrwxrwx   1 root root      10 Oct 14  2023 /etc/rc6.d -> rc.d/rc6.d
drwxr-xr-x. 10 root root    4096 Oct 14  2023 /etc/rc.d
drwxr-xr-x.  2 root root    4096 Apr 18  2022 /etc/reader.conf.d
drwxr-xr-x.  2 root root    4096 Oct  8  2021 /etc/request-key.d
drwxr-xr-x.  2 root root    4096 Oct 14  2023 /etc/rsyslog.d
drwxr-xr-x.  2 root root    4096 Nov 15 08:33 /etc/rwtab.d
drwxr-xr-x.  3 root root    4096 Sep  7  2021 /etc/sane.d
drwxr-xr-x.  2 root root    4096 Nov  9  2022 /etc/sddm.conf.d
drwxr-xr-x.  2 root root    4096 Oct  8  2021 /etc/sensors.d
drwxr-x---.  2 root root    4096 Apr  4  2023 /etc/sudoers.d
drwxr-xr-x.  2 root root    4096 Jul 17  2021 /etc/supervisord.d
drwxr-xr-x.  2 root root    4096 Oct 15  2023 /etc/sysctl.d
drwxr-xr-x.  2 root root    4096 Apr 12 11:42 /etc/tmpfiles.d
drwxr-xr-x.  2 root root    4096 Oct  9  2021 /etc/xinetd.d
drwxr-xr-x.  2 root root    4096 Apr 28  2023 /etc/yum.repos.d

Cron Example

$ ls -l /etc/cron.d
total 8
-rw-r--r--. 1 root root 128 Mar  6 09:37 0hourly
-rw-r--r--. 1 root root 108 Oct 14  2023 raid-check