#!/bin/sh # /etc/cron.daily/standard: standard daily maintenance script # Written by Ian A. Murdock # Modified by Ian Jackson # Modified by Steve Greenland # Start in the root filesystem, make SElinux happy cd / bak=/var/backups LOCKFILE=/var/lock/cron.daily umask 022 # # Avoid running more than one at a time # if [ -x /usr/bin/lockfile-create ] ; then lockfile-create $LOCKFILE if [ $? -ne 0 ] ; then cat </dev/null | awk '/\/dev\// { print }' | sed -e 's/ [[:space:]]*/ /g' | while read mount block used avail perc mp; do [ "$mp" = "/" ] && mp="" echo "$mp/lost+found" done` # Don't use space as a field separator oldifs="$IFS" IFS=`printf '\n\t'` for lfdir in $lfdirs; do # In each directory, look for files if [ -d "$lfdir" ] ; then more_lost_found=`ls -1 "$lfdir" 2>/dev/null | grep -v 'lost+found$' | sed 's/^/ /'` if [ -n "$more_lost_found" ] ; then lost_found="$lost_found $lfdir: $more_lost_found" # NOTE: above weird line breaks in string are intentional! fi else # Do nothing for XFS filesystems they do not need to # have a lost and found dir fs=`cat /proc/mounts | grep " ${lfdir%/lost+found} "` case "$fs" in ext*) no_lost_found="$no_lost_found $lfdir" ;; *) ;; esac fi done # Restore IFS IFS="$oldifs" unset oldifs # NOTE: This might need to be configurable if systems abound # w/o lost+found out there to prevent giving out this warning # every day. if [ -n "$lost_found" ]; then cat << EOF Files were found in lost+found directories. This is probably the result of a crash or bad shutdown, or possibly of a disk problem. These files may contain important information. You should examine them, and move them out of lost+found or delete them if they are not important. The following files were found: $lost_found EOF fi if [ -n "$no_lost_found" ]; then cat << EOF Some local filesystems do not have lost+found directories. This means that these filesystems will not be able to recover lost files when the filesystem is checked after a crash. Consider creating a lost+found directory with mklost+found(8). The following lost+found directories were not available: $no_lost_found EOF fi # # Clean up lockfile # if [ -x /usr/bin/lockfile-create ] ; then kill $LOCKTOUCHPID lockfile-remove $LOCKFILE fi