Subject: Re: hardware check in /etc/rc.local?
To: Bill Studenmund <skippy@macro.stanford.edu>
From: Andrew Gillham <gillhaa@ghost.whirlpool.com>
List: current-users
Date: 09/09/1996 23:15:48
Bill Studenmund wrote:
> 
> I have a question about this. I think the idea looks cool, but why go
> looking in /var/log/dmsglog? Doesn't the kernel export the message log for
> this boot in /kern/msglog? Why not just look in there?

/var/log/dmesglog is the _previous_ boot information.  This gets saved in
dmesglog.0, and the current boot info written to dmesglog  This is carried
over by some ports, but not others.  My i386 machine always has just the
most recent boot.  As for /kern/msgbuf instead of 'dmesg', I agree that
it would be the best way, but does depend on /kern being mounted.  I'm
not sure what percentage of the NetBSD population uses it.  I would rather
not depend on kernfs being in there if I don't absolutely have to.
I will look into adding a check for /kern/msgbuf to my code.

-Andrew

(for the interested, the latest version of the script, thanks to
Brian Baird (brb@exp.com) for the sed one-liner)

--- cut here ---

if [ -f /var/log/dmesglog ]; then
	echo -n 'checking hardware config:'
	mv /var/log/dmesglog /var/log/dmesglog.0
	dmesg | sed -n '/^NetBSD/h; /^NetBSD/!H; ${ x; p; q; }' \
		> /var/log/dmesglog
	diff -bc /var/log/dmesglog.0 /var/log/dmesglog > /tmp/diff.$$ 
	if [ -s /tmp/diff.$$ ]; then
		cat /tmp/diff.$$ | Mail -s "hardware change" root
		echo ' changed.'
	else
		echo ' no change.'
	fi
	rm -f /tmp/diff.$$
fi

--- cut here ---