home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s053 / 5.ddi / sbin / umountall < prev    next >
Encoding:
Text File  |  1990-12-08  |  2.2 KB  |  106 lines

  1. #!/sbin/sh
  2. #    Copyright (c) 1990 UNIX System Laboratories, Inc.
  3. #    Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T
  4. #      All Rights Reserved
  5.  
  6. #    THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF
  7. #    UNIX System Laboratories, Inc.
  8. #    The copyright notice above does not evidence any
  9. #    actual or intended publication of such source code.
  10.  
  11.  
  12.  
  13. #!/sbin/sh
  14. #ident    "@(#)/sbin/umountall.sl 1.1 4.0 12/08/90 12726 AT&T-USL"
  15. USAGE="Usage:\numountall [-F FSType] [-k] [-l|-r] "
  16. FSTAB=/etc/vfstab
  17. FSType=
  18. kill=
  19. FCNT=0
  20. CNT=0
  21. while getopts ?rlkF: c
  22. do
  23.     case $c in
  24.     r)    RFLAG="r"; CNT=`/usr/bin/expr $CNT + 1`;;
  25.     l)    LFLAG="l"; CNT=`/usr/bin/expr $CNT + 1`;;
  26.     k)     kill="yes";;
  27.     F)    FSType=$OPTARG; 
  28.         case $FSType in
  29.         ?????????*) 
  30.             echo "umountall: FSType $FSType exceeds 8 characters"
  31.             exit 2
  32.         esac;
  33.         FCNT=`/usr/bin/expr $FCNT + 1`;;
  34.     \?)    echo "$USAGE" 1>&2; exit 2;;
  35.     esac
  36. done
  37. shift `/usr/bin/expr $OPTIND - 1`
  38. if test $FCNT -gt 1
  39. then
  40.     echo "umountall: more than one FStype specified" 1>&2
  41.     exit 2
  42. fi
  43. if test $CNT -gt 1
  44. then
  45.     echo "umountall: options -r and -l incompatible" 1>&2
  46.     echo "$USAGE" 1>&2
  47.     exit 2
  48. fi
  49. if test $# -gt 0
  50. then
  51.     echo "umountall: arguments not supported" 1>&2
  52.     echo "$USAGE" 1>&2
  53.     exit 2
  54. fi
  55. if test \( "$FSType" = "rfs" -o "$FSType" = "nfs" \) -a "$LFLAG" = "l"
  56. then
  57.     echo "umountall: option -l and FSType are incompatible" 1>&2
  58.     echo "$USAGE" 1>&2
  59.     exit 2
  60. fi
  61. if test \( "$FSType" = "s5" -o "$FSType" = "ufs" -o "$FSType" = "bfs" \) -a "$RFLAG" = "r"
  62. then
  63.     echo "umountall: option -r and FSType are incompatible" 1>&2
  64.     echo "$USAGE" 1>&2
  65.     exit 2
  66. fi
  67.  
  68. /sbin/mount -v  |
  69.     /usr/bin/sort -r  |
  70.     while read dev dum1 mountp dum2 fstype mode dum3
  71.     do
  72.         case "${mountp}" in
  73.         /  | /stand | /proc | /dev/fdfs | '' )
  74.             continue
  75.             ;;
  76.         * )
  77.             if [ "$FSType" ]
  78.             then
  79.                 if test "$FSType" != "$fstype"
  80.                 then
  81.                     continue
  82.                 fi
  83.             fi
  84.             if test "$LFLAG" = "l"
  85.             then
  86.                 if test "$fstype" = "rfs" -o "$fstype" = "nfs"
  87.                 then
  88.                     continue
  89.                 fi
  90.             fi
  91.             if test "$RFLAG" = "r"
  92.             then
  93.                 if test "$fstype" != "rfs" -a "$fstype" != "nfs"
  94.                 then
  95.                     continue
  96.                 fi
  97.             fi
  98.             if [ ${kill} ]
  99.             then
  100.                 /usr/sbin/fuser -k ${dev}
  101.                 /usr/bin/sleep 10
  102.             fi
  103.             /sbin/umount ${dev}
  104.         esac
  105.     done 
  106.