This hasn't been updated in over a decade so maybe this will help someone or spark more efficient ways to maintain configuration files in Slackware.
A very simple revision control method may help keep configuration files sorted
out and available for comparison with new revisions.
More sophisticated methods exist using svn, mercurial, or even git, but this is
a very straight forward method.
A script may ease the process of processing new configuration files.
This could be automated further, but this a very basic way.
In this method, configuration file revisions are saved using the file modificaton date.
For example, a revision of a file
file.conf
is saved in the current directory as
file.conf.YYYYMMDD_hhmm
The more time consuming steps of this method involve retrieving and adding the
modification date.
A script can help here.
A script named cnm.sh was created to reduce the number of steps to create
revisions of configuration files.
Code:
#!/bin/bash
# file: cnm.sh
# date: 20240303
# desc: Make a copy of a file with a name using the modify date
# note: This script lives at /usr/local/sbin
# note: This script must be run from the command line as sudo
# if in a system directory.
# note: make cnm.sh executable: sudo chmod +x /usr/local/sbin/cnm.sh
fname=$(basename -- "$1")
fext="${fname##*.}"
# echo $fext
if [[ $fext = "new" ]]; then
cp -afp $1 `ls $1 | sed 's/\.new$//'`.`date -r $1 "+%Y%m%d_%H%M"`
else
# Can't use $fname with filenames like slackpkg.conf
cp -afp $1 $1.`date -r $1 "+%Y%m%d_%H%M"`
fi
The following is an example session which uses this script.
An upgrade with slackpkg may report several configuration files require attention.
Packages that had configuration changes
/etc/postfix/access.new
/etc/postfix/canonical.new
/etc/postfix/generic.new
/etc/postfix/header_checks.new
/etc/postfix/relocated.new
/etc/postfix/virtual.new
/etc/slackpkg/blacklist.new
/etc/slackpkg/mirrors.new
/etc/slackpkg/slackpkg.conf.new
So an example of a comparison and revision update session can be:
cd /etc/postfix/
sudo cnm access # make access.20230903_1339
sudo cnm access.new # make access.20240307_1458
sudo vi -d access access.new # modify access with access.new as necessary
sudo mv access.new access # or just replace with the new version
The as found listing for the postfix/access configuration files:
$ ls -l access*
-rw-r--r-- 1 root root 21111 Sep 3 2023 access
-rw-r--r-- 1 root root 21147 Mar 7 14:58 access.new
The as left listing for the postfix/access configuration files:
$ ls -l access*
-rw-r--r-- 1 root root 21147 Mar 7 14:58 access
-rw-r--r-- 1 root root 21111 Sep 3 2023 access.20230903_1339
-rw-r--r-- 1 root root 21147 Mar 7 14:58 access.20240307_1458
Most configurations are not uniquely modified and can be simply updated.
A quick review of the changes is always warranted prior to updating.
tkdiff is useful in these instances.
sudo cnm canonical
sudo cnm canonical.new
tkdiff cononical cononcial.new
sudo mv canonical.new canonical
sudo cnm generic
sudo cnm generic.new
tkdiff generic generic.new
sudo mv generic.new generic
sudo cnm header_checks
sudo cnm header_checks.new
tkdiff header_checks header_checks.new
sudo mv header_checks.new header_checks
sudo cnm relocated
sudo cnm relocated.new
tkdiff relocated relocated.new
sudo mv relocated.new relocated
sudo cnm virtual
sudo cnm virtual.new
tkdiff virtual virtual.new
sudo mv virtual.new virtual
Some new files are identical to existing revisions and are removed.
cd ../slackpkg/
sudo diff -s blacklist.20210531_1624 blacklist.new
Files blacklist.20210531_1624 and blacklist.new are identical
sudo rm blacklist.new
sudo diff -s mirrors.20240308_0939 mirrors.new
Files mirrors.20240308_0939 and mirrors.new are identical
sudo rm mirrors.new