From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f88e1,3e9b3f98cdb7ba87,start X-Google-Attributes: gidf88e1,public X-Google-Thread: 1164f8,3e9b3f98cdb7ba87,start X-Google-Attributes: gid1164f8,public X-Google-Thread: 1020c6,3e9b3f98cdb7ba87,start X-Google-Attributes: gid1020c6,public X-Google-Thread: 10b612,3e9b3f98cdb7ba87,start X-Google-Attributes: gid10b612,public X-Google-Thread: fb0d8,3e9b3f98cdb7ba87,start X-Google-Attributes: gidfb0d8,public X-Google-Thread: 116557,3e9b3f98cdb7ba87,start X-Google-Attributes: gid116557,public X-Google-ArrivalTime: 1991-08-18 01:35:25 PST Path: gmdzi!unido!mcsun!uunet!elroy.jpl.nasa.gov!usc!hela!hela.iti.org!scs From: scs@iti.org (Steve Simmons) Newsgroups: alt.sys.sun,comp.unix.admin,comp.unix.large,mi.sun,comp.unix.ultrix,comp.sys.dec Subject: Something you should add to /etc/rc . . . Message-ID: Date: 17 Aug 91 23:52:52 GMT Sender: usenet@iti.org (Hela News Manager) Organization: Industrial Technology Institute Xref: gmdzi alt.sys.sun:54377 comp.unix.admin:42513 comp.unix.large:285 comp.unix.ultrix:47400 comp.sys.dec:25080 Nntp-Posting-Host: hela.iti.org 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)