home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s053 / 4.ddi / sbin / diskadd < prev    next >
Encoding:
Text File  |  1990-12-08  |  4.9 KB  |  165 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. #ident    "@(#)/sbin/diskadd.sl 1.1 4.0 12/08/90 17278 AT&T-USL"
  12.  
  13. # This script is used for adding disk drives to AT&T UNIX System V Release 4.0
  14. # It runs adddisk or /etc/scsi/sadddisk to prompt the user for information 
  15. # about the disk.  The diskadd program builds the following files:
  16. # /tmp/partitions -- with the disk characteristics and partitions from the
  17. #                    user,
  18. # /tmp/addparts -- contains the names of additional partitions the user may
  19. #                  want in addition to the required standard ones,
  20. # /tmp/mkfs.data -- contains information about each filesystem which the user
  21. #                   wants made.
  22. #
  23. # support is added to call the saddisk command if given a scsi device name 
  24. # or if the device name is 1 and it is linked to the scsi dn.
  25.  
  26. trap 'trap "" 1 2 3 9 15;
  27.     set +e;
  28.     cd /;
  29.     echo "You have canceled the diskadd program.  "
  30.     rm -rf /var/spool/locks/.DISKADD.LOCK
  31. exit 2' 1 2 3 15
  32.  
  33. if [ -f /var/spool/locks/.DISKADD.LOCK ]
  34. then
  35.     echo "The diskadd program is currently being run and cannot be run"
  36.     echo "concurrently. Please retry this at a later time."
  37.     exit 1
  38. else
  39.     >/var/spool/locks/.DISKADD.LOCK
  40. fi
  41. echo "You have invoked the diskadd utility. The purpose of this utility is"
  42. echo "the set up of additional disk drives. This utility can destroy "
  43. echo "the existing data on the disk. Do you wish to continue?"
  44. echo "(Strike y or n followed by ENTER) "
  45. read cont
  46. if  [ "$cont" != "y" ] && [ "$cont" != "Y" ] 
  47. then
  48.     rm -rf /var/spool/locks/.DISKADD.LOCK
  49.     exit 0
  50. fi
  51.  
  52. set +e 
  53. if [ -n "$1" ]
  54. then
  55.     drive=$1
  56. else
  57.     machid -s
  58.     if [ "$?" = 1 ]
  59.     then
  60.         if [ -b /dev/dsk/c0t1d0s0 ]
  61.         then
  62.             drive=c0t1d0
  63.         else
  64.             # set to scsi to cause usage message
  65.             drive=scsi 
  66.         fi
  67.     else
  68.         # machine is esdi-based assume 2nd esdi drive
  69.         drive=1
  70.     fi
  71. fi
  72.  
  73. case $drive in
  74. 1) dn=01; devnm=/dev/rdsk/1s0; t_mnt=/dev/dsk/1s;;
  75. c?t?d?) # added for scsi devices
  76.  
  77.     slot=`echo $drive | cut -c2`
  78.     tc=`echo $drive | cut -c4`
  79.     drv=`echo $drive | cut -c6`
  80.     # add check for valid args
  81.  
  82.     dn=${slot}${tc}${drv}
  83.     devnm=/dev/rdsk/c${slot}t${tc}d${drv}s0
  84.     t_mnt=/dev/dsk/c${slot}t${tc}d${drv}s;;
  85.  
  86. *) echo "usage: $0 [1] ( for Second Disk )"; 
  87.    echo "usage: $0  cCtTdD  ( for SCSI Disks ) \n";
  88.    echo "Issued with [1] or without an argument $0 will"
  89.    echo "add the Second integral disk at /dev/rdsk/1s0."
  90.    echo "For a SCSI disk the argument must be in the form:"
  91.    echo "    Where C is the SCSI Host Adapter Controller number"
  92.    echo "          T is the Target ID on that Controller"
  93.    echo "    and   D is the Device ID at that Target."
  94.  
  95.    rm -rf /var/spool/locks/.DISKADD.LOCK
  96.    exit 1;; # added for scsi
  97. esac
  98. set +e
  99. /etc/mount | grep ${t_mnt} > /dev/null 2>&1
  100. if [ $? = 0 ]
  101. then echo "The device you wish to add cannot be added.\nIt is already mounted as a filesystem."
  102.      rm -rf /var/spool/locks/.DISKADD.LOCK
  103.      exit 1
  104. fi
  105.  
  106. ###################################################################################
  107. # If support for disks with > 1024 cyls (using a controller that doesn't provide 
  108. # transparent logical translation) is required, the following eight lines should be
  109. # uncommented. (This assumes the changes to disksetup and INSTALL were also made.)
  110. # set +e
  111. # disksetup -O $devnm
  112. # dOerr=$?
  113. # set -e
  114. # if [ $dOerr = 11 ]        # disk params are changed
  115. # then
  116. #     /sbin/disksetup -I $devnm
  117. # fi
  118. ###################################################################################
  119. set +x
  120.  
  121.  
  122. /sbin/fdisk $devnm 
  123. if [ $? != 0 ]
  124. then
  125.    echo "\n"
  126.    echo "usage: $0 [1] ( for Second Disk )"; 
  127.    echo "usage: $0  cCtTdD  ( for SCSI Disks ) \n";
  128.    echo "Issued with [1] or without an argument $0 will"
  129.    echo "add the Second integral disk at /dev/rdsk/1s0."
  130.    echo "For a SCSI disk the argument must be in the form:"
  131.    echo "    Where C is the SCSI Host Adapter Controller number"
  132.    echo "          T is the Target ID on that Controller"
  133.    echo "    and   D is the Device ID at that Target."
  134.    rm -rf /var/spool/locks/.DISKADD.LOCK
  135.    exit 1
  136. fi
  137.  
  138.     
  139. echo "\nDisk partitioning complete."
  140. if [ "$devnm" = "/dev/rdsk/1s0" ]
  141. then
  142.     sed '/\/dsk\/1s/d' /etc/vfstab >/etc/tmpvfstab
  143.     mv /etc/tmpvfstab /etc/vfstab
  144. fi
  145. /sbin/disksetup -I $devnm
  146. if [ $? != 0 ]
  147. then
  148.    echo "\n"
  149.    echo "The Installation of the disk has failed."
  150.    echo "Received error return value from /sbin/disksetup."
  151.    echo "Please verify your disk is connected correctly."
  152.    rm -rf /var/spool/locks/.DISKADD.LOCK
  153.    exit 1
  154. fi
  155. /sbin/prtvtoc -e $devnm >/dev/null
  156. # Run the mkdtab commands to update device.tab to include new disk
  157. /usr/sadm/sysadm/bin/mkdtab
  158. if [ -f /etc/scsi/scsimkdtab ]
  159. then
  160.     /etc/scsi/scsimkdtab
  161. fi
  162. rm -rf /var/spool/locks/.DISKADD.LOCK
  163. echo "Diskadd for" disk$dn "DONE at" `date`
  164. exit 0
  165.