home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1999 March B / SCO_CASTOR4RRT.iso / base / root.15 / sbin / mountall / mountall~
Text File  |  1998-08-19  |  7KB  |  270 lines

  1. #! /sbin/sh
  2.  
  3. # Copyright (c) 1998 The Santa Cruz Operation, Inc.. All Rights Reserved. 
  4. #                                                                         
  5. #        THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF THE               
  6. #                   SANTA CRUZ OPERATION INC.                             
  7. #                                                                         
  8. #   The copyright notice above does not evidence any actual or intended   
  9. #   publication of such source code.                                      
  10.  
  11.  
  12. #    Copyright (c) 1993 UNIX System Laboratories, Inc.
  13. #      All Rights Reserved
  14.  
  15. #    THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF
  16. #    UNIX System Laboratories, Inc.       
  17. #    The copyright notice above does not evidence any
  18. #    actual or intended publication of such source code.
  19.  
  20. #    copyright    "%c%"
  21.  
  22. #ident    "@(#)initpkg:i386/cmd/initpkg/mountall.sh    1.18.24.9"
  23.  
  24. if [ -z "$LC_ALL" -a -z "$LC_MESSAGES" ]
  25. then
  26.     if [ -z "$LANG" ]
  27.     then
  28.         LNG=`defadm locale LANG 2>/dev/null`
  29.         if [ "$?" != 0 ]
  30.         then LANG=C
  31.         else eval $LNG
  32.         fi
  33.     fi
  34.     LC_MESSAGES=/etc/inst/locale/$LANG
  35.     export LANG LC_MESSAGES
  36. fi
  37. LABEL="UX:$0"
  38.  
  39. CAT=uxrc; export CAT
  40.  
  41. usage()
  42. {
  43. FARG=`gettxt $CAT:57 "FSType"`
  44. ARG=`gettxt $CAT:58 "file_system_table"`
  45. USAGE="mountall [-F $FARG] [-l|-r] [$ARG]"
  46. pfmt -l $LABEL -s action -g $CAT:4 "Usage: %s\n" "$USAGE"
  47. exit 2
  48. }
  49. TYPES="all"
  50.  
  51. while getopts ?rlF: c
  52. do
  53.     case $c in
  54.     r)    RFLAG="r";;
  55.     l)    LFLAG="l";;
  56.     F)    FSType=$OPTARG;
  57.         if [ "$TYPES" = "one" ]
  58.         then
  59.             pfmt -l $LABEL -s error -g $CAT:59 "more than one FSType specified\n"
  60.             exit 2
  61.         else
  62.             TYPES="one"
  63.         fi;
  64.         case $FSType in
  65.         ?????????*) 
  66.             pfmt -l $LABEL -s error -u $CAT:60 "FSType %s exceeds 8 characters\n" $FSType
  67.             exit 2
  68.         esac
  69.         ;;
  70.     \?)    usage
  71.         ;;
  72.     esac
  73. done
  74. shift `expr $OPTIND - 1`
  75. if [ "$RFLAG" = "r" -a "$LFLAG" = "l" ]
  76. then
  77.     pfmt -l $LABEL -s error -g $CAT:61 "options -r and -l incompatible\n"
  78.     usage
  79. fi
  80. if [ $# -gt 1 ]
  81. then
  82.     pfmt -l $LABEL -s error -g $CAT:62 "multiple arguments not supported\n"
  83.     usage
  84. fi
  85.  
  86. # get file system table name and make sure file exists
  87. case $1 in
  88.     "-")    FSTAB=""
  89.         ;;
  90.     "")    FSTAB=/etc/vfstab
  91.         ;;
  92.     *)    FSTAB=$1
  93.         ;;
  94. esac
  95. if [ "$FSTAB" != ""  -a  ! -s "$FSTAB" ]
  96. then
  97.     pfmt -l $LABEL -s error -g $CAT:63 "file system table (%s) not found\n" $FSTAB
  98.     exit 1
  99. fi
  100.  
  101. if [ \( "$FSType" = "rfs" -o "$FSType" = "nfs" \) -a "$LFLAG" = "l" ]
  102. then
  103.     pfmt -l $LABEL -s error -g $CAT:64 "option -l and FSType are incompatible\n"
  104.     usage
  105. fi
  106. if [ \( "$FSType" = "s5" -o "$FSType" = "ufs" -o "$FSType" = "bfs" -o "$FSType" = "sfs" \) -a "$RFLAG" = "r" ]
  107. then
  108.     pfmt -l $LABEL -s error -g $CAT:65 "option -r and FSType are incompatible\n"
  109.     usage
  110. fi
  111.  
  112. #    file-system-table format:
  113. #
  114. #    column 1:    special- block special device or resource name
  115. #    column 2:     fsckdev- char special device for fsck 
  116. #    column 3:    mountp- mount point
  117. #    column 4:    fstype- File system type
  118. #    column 5:    fsckpass- number if to be checked automatically
  119. #    column 6:    automnt-    yes/no for automatic mount
  120. #    column 7:    mntopts- -o specific mount options
  121. #    column 8:    macceiling when security is installed, fs MAC ceiling
  122.  
  123. #    White-space separates columns.
  124. #    Lines beginning with \"#\" are comments.  Empty lines are ignored.
  125. #    a '-' in any field is a no-op.
  126.  
  127.     exec < $FSTAB
  128.     while  read special fsckdev mountp fstype fsckpass automnt mntopts macceiling
  129.     do
  130.         case $special in
  131.         '#'* | '')    #  Ignore comments, empty lines
  132.                 continue ;;
  133.         '-')        #  Ignore no-action lines
  134.                 continue
  135.         esac 
  136.         
  137.         if  [ "$FSType" ]
  138.         then            # ignore different fstypes
  139.             if [ "$FSType" != "$fstype" ]
  140.             then
  141.                 continue
  142.             fi
  143.         fi
  144.  
  145.         if [ "$LFLAG" ]
  146.         then
  147.             if [ "$fstype" = "rfs"  -o  "$fstype" = "nfs" ]
  148.             then
  149.                 continue
  150.             fi
  151.         fi
  152.         if [ "$RFLAG" ]
  153.         then
  154.             if [ "$fstype" != "rfs" -a  "$fstype" != "nfs" ]
  155.             then
  156.                 continue
  157.             fi
  158.         fi
  159.         if [ "$automnt" != "yes" ]
  160.         then
  161.             continue
  162.         fi
  163.         if [ "$fstype" = "-" ]
  164.         then
  165.             pfmt -l $LABEL -s error -g $CAT:66 "FSType of %s cannot be identified\n" $special
  166.             continue
  167.         fi
  168.         #     Use mount options if any
  169.         if  [ "$mntopts" != "-" ]
  170.         then
  171.             OPTIONS="-o $mntopts"
  172.         else
  173.             OPTIONS=""
  174.         fi
  175.  
  176.         # check if mac is installed and if macceiling in vfstab
  177.         # is not equal to null or "-"
  178.         mldmode >/dev/null 2>&1
  179.         if [ "$?" != "0" ]
  180.         then
  181.             lflg=""
  182.         else
  183.             if [ -n "$macceiling"  -a "$macceiling" != "-" ]
  184.             then
  185.                 lflg="-l $macceiling"
  186.             else
  187.                 lflg=""
  188.             fi
  189.         fi
  190.  
  191.  
  192.         #    First check file system state and repair if necessary.
  193.  
  194.         if [ "$fsckdev" = "-" ]
  195.         then
  196.             /sbin/mount $lflg "-F" $fstype $OPTIONS $special $mountp
  197.             continue
  198.         fi
  199.  
  200.         /sbin/mount $lflg "-F" $fstype $OPTIONS $special $mountp
  201.         if [ $? -eq 0 ]
  202.         then
  203.             [ "$mountp" = "/usr" ] && /sbin/initprivs 2> /dev/null
  204.             continue
  205.         fi
  206.         #msg=`/sbin/fsck "-m" "-F" $fstype $special 2>&1 </dev/null`
  207.         /sbin/fsck "-m" "-F" $fstype $special >/dev/null 2>&1
  208.         case $? in
  209.         0)    /sbin/mount $lflg "-F" $fstype $OPTIONS $special $mountp
  210.             [ "$mountp" = "/usr" ] && /sbin/initprivs 2> /dev/null
  211.             ;;
  212.  
  213.         32)    if [ ! -f /etc/.fscklog ]
  214.             then
  215.                 echo > /etc/.fscklog
  216.                 pfmt -l $LABEL -s info -g $CAT:53 "\nPlease wait while the system is examined.  This may take a few minutes.\n\n"
  217.             fi
  218.             #echo "$msg\n"
  219.             #pfmt -s nostd -g $CAT:24 "\t %s is being checked\n" $fsckdev
  220.             if [ "$fstype" != "s5" ]
  221.             then
  222.                 /sbin/fsck "-F" $fstype -y $fsckdev >/dev/null
  223.             else 
  224.                 /sbin/fsck "-F" $fstype -y -t /var/tmp/tmp$$ -D $fsckdev >/dev/null
  225.             fi
  226.             if [ $? -eq 0 ]
  227.             then
  228.                 /sbin/mount $lflg "-F" $fstype $OPTIONS $special $mountp
  229.                 [ "$mountp" = "/usr" ] && /sbin/initprivs 2> /dev/null
  230.             else
  231.                 pfmt -l $LABEL -s info -g $CAT:67 "%s not mounted\n" $special
  232.             fi
  233.             ;;
  234.  
  235.         33)    # already mounted
  236.             #
  237.             # if the mount point is "/usr" execute /sbin/initprivs
  238.             # here since the administrator may have mounted "/usr"
  239.             # without doing a manual /sbin/initprivs.  The reason this
  240.             # is required here is because once "/usr" is mounted the
  241.             # file system dependent commands are executed from the
  242.             # /usr/lib/fs/[fs_type] directory instead of the
  243.             # /etc/fs/[fs_type] directory.
  244.             #
  245.             # If this is not done here the possibility exists that
  246.             # some file systems may not get mounted and commands
  247.             # that require privilege may not execute properly.
  248.             #
  249.             [ "$mountp" = "/usr" ] && /sbin/initprivs 2> /dev/null
  250.             pfmt -l $LABEL -s info -g $CAT:68 "%s already mounted\n" $special
  251.             ;;
  252.  
  253.         39)    pfmt -l $LABEL -s error -g $CAT:69 "%s could not be read\n" $special
  254.             ;;
  255.  
  256.         1|36)    pfmt -l $LABEL -s error -g $CAT:70 "fsck failed for %s\n" $special
  257.             ;;
  258.         esac
  259.  
  260.     done
  261.  
  262. # execute ``/sbin/initprivs'' one  more  time.  This shouldn't
  263. # take too long and will report  via  diagnostic  messages any
  264. # discrepancies found between the Privilege Data File and  the
  265. # files on disk.
  266.  
  267. wait
  268. /sbin/initprivs
  269. exit 0
  270.