home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume1 / 8712 / 12 < prev    next >
Internet Message Format  |  1990-07-13  |  3KB

  1. Path: uunet!husc6!rutgers!clyde!cbosgd!mandrill!hal!ncoast!allbery
  2. From: davidsen@UUNET.UU.NET@steinmetz.UUCP
  3. Newsgroups: comp.sources.misc
  4. Subject: A shell script to create lost+found
  5. Keywords: shell, lost+found
  6. Message-ID: <6905@ncoast.UUCP>
  7. Date: 26 Dec 87 02:48:23 GMT
  8. Sender: allbery@ncoast.UUCP
  9. Organization: GE Corp. R & D, Schenectady,NY
  10. Lines: 77
  11. Approved: allbery@ncoast.UUCP
  12. X-Archive: comp.sources.misc/8712/12
  13.  
  14. [Some people seem to feel that rules are made to be broken:  I had to create
  15. the shar file for this, and since I've been working late recently it's about
  16. two weeks late in posting.  Moral:  Follow the guidelines!  ++bsa]
  17.  
  18. Some of the varieties of UNIX don't create a lost+found directory
  19. in mkfs. Some don't even have a utility to make it for you. This script
  20. was presented at the December meeting of *IX and seems generally useful.
  21. It creates a lost+found on each mounted filesys which needs it, leaves
  22. existing directories alone, and doesn't get upset if a volume is mounted
  23. read only.
  24.  
  25. Please send any comments to the original author, his address is in the
  26. comments of the script.
  27.  
  28. #--------------------------------CUT HERE-------------------------------------
  29. #! /bin/sh
  30. #
  31. # This is a shell archive.  Save this into a file, edit it
  32. # and delete all lines above this comment.  Then give this
  33. # file to sh by executing the command "sh file".  The files
  34. # will be extracted into the current directory owned by
  35. # you with default permissions.
  36. #
  37. # The files contained herein are:
  38. #
  39. # -rw-r--r--   1 allbery  System       744 Dec 25 21:44 mklost+found
  40. #
  41. echo 'x - mklost+found'
  42. if test -f mklost+found; then echo 'shar: not overwriting mklost+found'; else
  43. sed 's/^X//' << '________This_Is_The_END________' > mklost+found
  44. X#!/bin/sh
  45. X#
  46. X# make lost+found
  47. X#    author: Brian Fitzgerald (uunet!steinmetz!sixhub!sixbdf!root)
  48. X#
  49. X# Creates a lost+found directory in any mounted partition in
  50. X# which it does not exist.
  51. X
  52. Xfor partition in `mount | awk '{print $1}'`
  53. Xdo
  54. X    cd $partition
  55. X    if [ -d lost+found ]
  56. X    then
  57. X        echo "$partition/lost+found already exists, nothing done to $partition"
  58. X    else
  59. X        echo "Making lost+found directory for $partition"
  60. X        mkdir "lost+found" ||
  61. X        {    # This happens if mounted read only
  62. X            echo "Can't create dir in $partition"
  63. X            continue;
  64. X        }
  65. X        cd lost+found
  66. X        count=0
  67. X        echo "Creating dummy files"
  68. X        while [ $count != 128 ]
  69. X        do
  70. X            echo >file$count
  71. X            count=`expr $count + 1`
  72. X        done
  73. X        echo "Removing dummy files"
  74. X        rm *
  75. X        cd ..
  76. X        ls -ld lost+found
  77. X    fi
  78. Xdone
  79. ________This_Is_The_END________
  80. if test `wc -l < mklost+found` -ne 35; then
  81.     echo 'shar: mklost+found was damaged during transit (should have been 35 bytes)'
  82. fi
  83. fi        ; : end of overwriting check
  84. exit 0
  85.  
  86.  
  87. -- 
  88.     bill davidsen        (wedu@ge-crd.arpa)
  89.   {uunet | philabs | seismo}!steinmetz!crdos1!davidsen
  90. "Stupidity, like virtue, is its own reward" -me
  91.