Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
* Something you should add to /etc/rc . . .
@ 1991-08-17 23:52 Steve Simmons
  0 siblings, 0 replies; only message in thread
From: Steve Simmons @ 1991-08-17 23:52 UTC (permalink / raw)


Was lurking thru my home system the other day, and found some files
lying around in one of the lost+found directories.  That made me
write this little script fragment to check it out:

---------------- start cut -----------------
for MOUNT in `awk '{ if ( $3 == "4.2" ) print $2 }' < /etc/fstab`
do
	if [ -d $MOUNT/lost+found ] ; then
		cd $MOUNT/lost+found
		if [ 2 != `ls -a | wc -l` ] ; then
			echo There are files to look at in $MOUNT/lost+found.
		fi
	else
		echo Warning -- no lost+found directory in $MOUNT.
	fi
done
---------------- end cut ----------------------

That's a handy thing to run once in while in general, but it seemed
the best time was immediately after boot.  So a modified version got
put into /etc/rc as the very last thing:

---------------- start cut -----------------
#
#  Check for dead files in the lost+found directories
#
echo -n "Checking lost+found directories . . . "
LOGFILE=/tmp/lostfiles
for MOUNT in `awk '{ if ( $3 == "4.2" ) print $2 }' < /etc/fstab`
do
        if [ -d $MOUNT/lost+found ] ; then
                cd $MOUNT/lost+found
                if [ 2 != `ls -a | wc -l` ] ; then
                        echo There are files to look at in $MOUNT/lost+found.
                fi
        else
                echo Warning -- no lost+found directory in $MOUNT.
        fi
done > $LOGFILE
if [ 0 != `wc -l < $LOGFILE` ] ; then
        mail -s "Lost+Found Errors Found At Boot" root < $LOGFILE
        echo "damage found.  Description sent to root."
else
        echo "no damage found."
fi
rm -f $LOGFILE
---------------- end cut -----------------

Rebooting a sun with this addition gave an error message about "wc not
found", so I added /usr/ucb to the PATH immediately after /usr/bin.
This cured one outstanding problem -- lokkur always gave an error
message "whoami not found" during boot.  This message is now gone.

Minor hacks to the awk statement would be needed for Ultrix, but
most other BSD-based systems can use this as is.
-- 
When Charlemagne returned from a campaign and discovered his wife in bed with
one of his ministers, he said to the man, "I don't understand.  I **have** to
sleep with her."   -- as told by Roy Richter (rrichter@ph.gmr.com)


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1991-08-17 23:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1991-08-17 23:52 Something you should add to /etc/rc . . Steve Simmons

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox