home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1999 March B / SCO_CASTOR4RRT.iso / base / root.15 / etc / diskmgmt / s5dm / diskadd / diskadd~
Text File  |  1998-08-19  |  5KB  |  163 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. #ident    "@(#)pdi.cmds:diskadd.sh    1.3.7.1"
  12.  
  13. # This script is used for adding disk drives to the UNIX System.
  14.  
  15. label=UX:diskadd
  16. msgdb=uxdiskadd
  17.  
  18. usage() {
  19.     pfmt -l $label -s action -g $msgdb:1 "\nusage: diskadd [-F s5dm] [1] ( for Second Disk )\n"
  20.     pfmt -l $label -s nostd -g $msgdb:2 "usage: diskadd [-F s5dm] cCCbBtTTdDD ( for additional Disks )\n\n"
  21.     pfmt -l $label -s nostd -g $msgdb:3 "Issued with [1] or without an argument diskadd will\nadd the Second disk with the appropriate name.\n"
  22.     pfmt -l $label -s nostd -g $msgdb:4 "For any additional disks, the argument must be in the form:\n\n"
  23.     pfmt -l $label -s nostd -g $msgdb:5 "        cCCbBtTTdDD\n\n"
  24.     pfmt -l $label -s nostd -g $msgdb:6 "        Where CC is the PDI Controller number (1-2 digits)\n"
  25.     pfmt -l $label -s nostd -g $msgdb:7 "              B  is the Bus ID on that Controller (1 digit)\n"
  26.     pfmt -l $label -s nostd -g $msgdb:8 "              TT is the Target ID on that Bus (1-2 digits)\n"
  27.     pfmt -l $label -s nostd -g $msgdb:9 "        and   DD is the Logical Unit on that Target (1-2 digits).\n"
  28. }
  29.  
  30. lockfile="/var/tmp/DISKADD.LOCK"
  31.  
  32. trap 'trap "" 1 2 3 9 15;
  33.     pfmt -l $label -s info -g $msgdb:10 "You have canceled the diskadd program.  \n"
  34.     rm -f $lockfile
  35. exit 2' 1 2 3 15
  36.  
  37. if [ -f $lockfile ]
  38. then
  39.     pfmt -l $label -s error -g $msgdb:11 "The diskadd program is currently being run and cannot be run concurrently.\n"
  40.     pfmt -l $label -s action -g $msgdb:12 "Please retry this at a later time.\n"
  41.     exit 1
  42. else
  43.     >$lockfile
  44. fi
  45.  
  46. y=`gettxt $msgdb:13 "y"`
  47. Y=`gettxt $msgdb:14 "Y"`
  48. n=`gettxt $msgdb:15 "n"`
  49. N=`gettxt $msgdb:16 "N"`
  50. pfmt -l $label -s info -g $msgdb:17 "You have invoked the System V disk management (s5dm) diskadd utility.\n"
  51. pfmt -l $label -s nostd -g $msgdb:18 "The purpose of this utility is to set up additional disk drives.\n"
  52. pfmt -l $label -s nostd -g $msgdb:19 "This utility can destroy the existing data on the disk.\n"
  53. pfmt -l $label -s nostd -g $msgdb:20 "Do you wish to continue?\n"
  54. pfmt -l $label -s nostd -g $msgdb:21 "(Type %s for yes or %s for no followed by ENTER): \n" "$y" "$n"
  55. read cont
  56. if  [ "$cont" != "$y" ] && [ "$cont" != "$Y" ] 
  57. then
  58.     rm -f $lockfile
  59.     exit 0
  60. fi
  61.  
  62. if [ -n "$1" ]
  63. then
  64.     drive=$1
  65. else
  66.     drive=1
  67. fi
  68.  
  69. case $drive in
  70. 1)    # add the default second disk device
  71.     dn=`devattr disk2 desc 2>&1`
  72.     ret=$?
  73.     if [ $ret = 2 ]
  74.     then
  75.         echo "$dn"
  76.         rm -f $lockfile
  77.         exit 1
  78.     elif [ $ret != 0 ]
  79.     then
  80.         pfmt -l $label -s error -g $msgdb:22 "\nThere does not seem to be a second disk present on your system.\n"
  81.         pfmt -l $label -s action -g $msgdb:23 "Please verify your disk is connected correctly.\n"
  82.         usage
  83.         rm -f $lockfile
  84.         exit 1
  85.     fi
  86.     devnm=`devattr disk2 cdevice`
  87.     t_mnt=`devattr disk2 bdevice`
  88.     length=`expr length $t_mnt - 1`
  89.     t_mnt=`expr substr $t_mnt 1 $length`
  90.     ;;
  91.  
  92. c?b?t?d? | \
  93. c?b?t?d?? | \
  94. c?b?t??d? | \
  95. c?b?t??d?? | \
  96. c??b?t?d? | \
  97. c??b?t?d?? | \
  98. c??b?t??d? | \
  99. c??b?t??d??) # added for scsi devices
  100.  
  101.     dn=`devattr /dev/dsk/${drive}s0 desc 2>&1`
  102.     ret=$?
  103.     if [ $ret = 2 ]
  104.     then
  105.         echo "$dn"
  106.         rm -f $lockfile
  107.         exit 1
  108.     elif [ $ret != 0 ]
  109.     then
  110.         pfmt -l $label -s error -g $msgdb:24 "\n%s does not seem to be present on your system.\n" "$drive"
  111.         pfmt -l $label -s action -g $msgdb:23 "Please verify your disk is connected correctly.\n"
  112.         usage
  113.         rm -f $lockfile
  114.         exit 1
  115.     fi
  116.     devnm="/dev/rdsk/${drive}s0"
  117.     t_mnt="/dev/dsk/${drive}s"
  118.     ;;
  119.  
  120. *)    usage
  121.     rm -f $lockfile
  122.     exit 1 # added for scsi
  123.     ;;
  124.  
  125. esac
  126.  
  127. /etc/mount | grep ${t_mnt} > /dev/null 2>&1
  128. if [ $? = 0 ]
  129. then
  130.     pfmt -l $label -s error -g $msgdb:25 "The device you wish to add cannot be added.\n"
  131.     pfmt -l $label -s info -g $msgdb:26 "It already has a mounted filesystem on it.\n"
  132.     rm -f $lockfile
  133.     exit 1
  134. fi
  135.  
  136. /usr/sbin/fdisk -I $devnm 
  137. if [ $? != 0 ]
  138. then
  139.     pfmt -l $label -s error -g $msgdb:27 "\nThe Installation of the disk has failed.\n"
  140.     pfmt -l $label -s info -g $msgdb:28 "Received error return value from %s.\n" "/usr/sbin/fdisk"
  141.     pfmt -l $label -s action -g $msgdb:23 "Please verify your disk is connected correctly.\n"
  142.     usage
  143.     rm -f $lockfile
  144.     exit 1
  145. fi
  146.  
  147. echo
  148.  
  149. /usr/sbin/disksetup -I $devnm
  150. if [ $? != 0 ]
  151. then
  152.     pfmt -l $label -s error -g $msgdb:27 "\nThe Installation of the disk has failed.\n"
  153.     pfmt -l $label -s info -g $msgdb:28 "Received error return value from %s.\n" "/usr/sbin/disksetup"
  154.     pfmt -l $label -s action -g $msgdb:23 "Please verify your disk is connected correctly.\n"
  155.     usage
  156.     rm -f $lockfile
  157.     exit 1
  158. fi
  159.  
  160. rm -f /etc/scsi/pdi_edt $lockfile
  161. pfmt -l $label -s info -g $msgdb:29 "Diskadd for %s DONE at %s\n" "$dn" "`date`"
  162. exit 0
  163.