Subject: admin/15629: Spotting configuration changes
To: None <gnats-bugs@gnats.netbsd.org>
From: seebs <seebs@ged.plethora.net>
List: netbsd-bugs
Date: 02/16/2002 00:38:15
>Number: 15629
>Category: admin
>Synopsis: Wouldn't it be nice if you got notified at boot about changes?
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: netbsd-admin
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Fri Feb 15 23:40:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: seebs
>Release: NetBSD 1.5ZA
>Organization:
N/A
>Environment:
System: NetBSD ged.plethora.net 1.5ZA NetBSD 1.5ZA (GED) #0: Sat Feb 16 00:05:37 CST 2002 seebs@ged.plethora.net:/usr/src/sys/arch/i386/compile/GED i386
Architecture: i386
Machine: i386
>Description:
BSD/OS has this cool feature where it says things like "Configuration
changed:" followed by diffs showing any changes in dmesg output. This
can be very handy when debugging.
At the same time, there's also a /var/db/dmesg.boot showing what the
system's boot-time configuration was like.
>How-To-Repeat:
Boot a system. :)
>Fix:
Save this script as /sbin/chkconfig. In /etc/rc, right near the end, add:
---
echo "Checking system configuration..."
chkconfig
---
I put it before the 'date' at the end.
This script is structurally fairly similar to the BSD/OS chkconfig, and in
particular, that's where I got the idea for the sed script.
The chkconfig man page is pretty trivial, but could be written if there's
any interest.
#!/bin/sh
umask 022
old=/var/db/dmesg.boot
new=/tmp/ck$$.dmesg
out=/tmp/ck$$.out
dmesg | sed -n -e '/^NetBSD/ { x ; n ; }' -e 'H' -e '$ { x ; p ; }' > $new
if [ ! -f $old ]
then echo >&2 "No old configuration to compare with."
cp $new $old
exit 1
fi
diff $old $new > $out
if [ -s $out ]
then echo >&2 "Configuration changed:"
cat $out
R=1
else R=0
fi
cp $new $old
rm -f $new $out
exit $R
>Release-Note:
>Audit-Trail:
>Unformatted: