home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / etc / cron.daily / standard < prev    next >
Encoding:
Text File  |  2006-12-20  |  3.2 KB  |  122 lines

  1. #!/bin/sh
  2. # /etc/cron.daily/standard: standard daily maintenance script
  3. # Written by Ian A. Murdock <imurdock@gnu.ai.mit.edu>
  4. # Modified by Ian Jackson <ijackson@nyx.cs.du.edu>
  5. # Modified by Steve Greenland <stevegr@debian.org>
  6.  
  7. # Start in the root filesystem, make SElinux happy
  8. cd /
  9. bak=/var/backups
  10. LOCKFILE=/var/lock/cron.daily
  11. umask 022
  12.  
  13. #
  14. # Avoid running more than one at a time 
  15. #
  16.  
  17. if [ -x /usr/bin/lockfile-create ] ; then
  18.     lockfile-create $LOCKFILE
  19.     if [ $? -ne 0 ] ; then
  20.     cat <<EOF
  21.  
  22. Unable to run /etc/cron.daily/standard because lockfile $LOCKFILE
  23. acquisition failed. This probably means that the previous day's
  24. instance is still running. Please check and correct if necessary.
  25.  
  26. EOF
  27.     exit 1
  28.     fi
  29.  
  30.     # Keep lockfile fresh
  31.     lockfile-touch $LOCKFILE &
  32.     LOCKTOUCHPID="$!"
  33. fi
  34.  
  35. #
  36. # Backup key system files
  37. #
  38.  
  39. if cd $bak ; then
  40.     cmp -s passwd.bak /etc/passwd || (cp -p /etc/passwd passwd.bak &&
  41.                       chmod 600 passwd.bak)
  42.     cmp -s group.bak /etc/group || (cp -p /etc/group group.bak &&
  43.                     chmod 600 group.bak)
  44.         if [ -f /etc/shadow ] ; then
  45.       cmp -s shadow.bak /etc/shadow || (cp -p /etc/shadow shadow.bak &&
  46.                                             chmod 600 shadow.bak)
  47.     fi
  48.         if [ -f /etc/gshadow ] ; then
  49.       cmp -s gshadow.bak /etc/gshadow || (cp -p /etc/gshadow gshadow.bak &&
  50.                           chmod 600 gshadow.bak)
  51.     fi
  52. fi
  53.  
  54. if cd $bak ; then
  55.     if ! cmp -s dpkg.status.0 /var/lib/dpkg/status ; then
  56.         cp -p /var/lib/dpkg/status dpkg.status
  57.         savelog -c 7 dpkg.status >/dev/null
  58.     fi
  59. fi
  60. #
  61. # Check to see if any files are in lost+found directories and warn admin
  62. #
  63. # Get a list of the (potential) ext2, ext3 and xfs l+f directories
  64. df -P --type=ext2 --type=ext3 --type=xfs |
  65. awk '/\/dev\// { print }' | sed -e 's/ [[:space:]]*/ /g'  |
  66. while read mount block used avail perc mp; do
  67.     [ "$mp" = "/" ] && mp=""
  68.     echo "$mp/lost+found"
  69. done |
  70. while read lfdir; do
  71. # In each directory, look for files
  72.     if [ -d "$lfdir" ] ; then
  73.     more_lost_found=`ls -1  "$lfdir" | grep -v 'lost+found$' | sed 's/^/    /'`
  74.     if [ -n "$more_lost_found" ] ; then
  75.         lost_found="$lost_found
  76.  
  77. $lfdir:
  78. $more_lost_found"
  79.         # NOTE: above weird line breaks in string are intentional!
  80.         fi
  81.     else
  82.         no_lost_found="$no_lost_found
  83. $lfdir"
  84.     fi
  85. done
  86.  
  87. # NOTE: This might need to be configurable if systems abound
  88. # w/o lost+found out there to prevent giving out this warning
  89. # every day.
  90. if [ -n "$lost_found" ]; then
  91.     cat << EOF
  92. Files were found in lost+found directories. This is probably
  93. the result of a crash or bad shutdown, or possibly of a disk
  94. problem. These files may contain important information. You
  95. should examine them, and move them out of lost+found or delete
  96. them if they are not important.
  97.  
  98. The following files were found:
  99. $lost_found
  100. EOF
  101. fi
  102.  
  103. if [ -n "$no_lost_found" ]; then
  104.     cat << EOF
  105. Some local filesystems do not have lost+found directories. This
  106. means that these filesystems will not be able to recover
  107. lost files when the filesystem is checked after a crash.
  108. Consider creating a lost+found directory with mklost+found(8).
  109.  
  110. The following lost+found directories were not available:
  111. $no_lost_found
  112. EOF
  113. fi
  114.  
  115. #
  116. # Clean up lockfile
  117. #
  118. if [ -x /usr/bin/lockfile-create ] ; then
  119.     kill $LOCKTOUCHPID
  120.     lockfile-remove $LOCKFILE
  121. fi
  122.