Subject: Re: hardware check in /etc/rc.local?
To: None <thorpej@nas.nasa.gov>
From: Andrew Gillham <gillhaa@ghost.whirlpool.com>
List: current-users
Date: 09/05/1996 02:54:03
Part 2... :)

I revised the code slightly, to take into account the fact that
dmesg may have multiple "boot logs."  By looking for a line beginning
with 'NetBSD', and grabbing everything from that line on, I then have
the last boot log.  But, if the message buffer has overflowed because
of the number of devices, looking for the regexp '^NetBSD' won't
work.  This all works if I reverse the output of dmesg (via tail -r) and
search for the _first_ (which is the _last_ really) occurence of '^NetBSD.'
If '^NetBSD' is found, sed quits, and the output is reversed again, so
it is back to normal.  This results in the last boot information if there
is more than one, otherwise the whole output.  This works fine on my 
i386 system, but I can't test it on the sparc at the moment.
This seems to cover the possibilities, but.. :)

-Andrew

-- snip --

if [ -f /var/log/dmesglog ]; then
	echo -n 'checking hardware config:'
	mv /var/log/dmesglog /var/log/dmesglog.0
	dmesg | tail -r | sed /^NetBSD/q | tail -r > /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

-- snip --