home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1998 October / VPR9810B.BIN / BIOS / free / sis49x / sis49x.exe / SIS.TAR / tmp / init.sis next >
Text File  |  1995-03-03  |  4KB  |  143 lines

  1. :
  2. #
  3. #       @(#) init.sis 1.0 02/20/95
  4. #
  5. #       Copyright (C) Silicon Integrated Systems Corp. 1995-1996 
  6. #
  7. #
  8. #
  9. PATH=/bin:/usr/bin:/etc
  10. tmp=/tmp/sis$$
  11. perm="/etc/perms/sis"               # permlist of this product
  12. PERM=/etc/perms/inst                    # OS (link kit) permlist
  13. set="SiS PCI IDE Device Driver Ver. 1.01 Package"
  14. _THIRDPARTY=                            # only true if 3rd party s/w exists
  15. _RELINK=                                # gets set to true by SAMI if nec.
  16. CONFDIR=/etc/conf/cf.d
  17.  
  18. : ${OK=0} ${FAIL=1} ${TRUE=0} ${FALSE=1}
  19.  
  20. # Function Definition
  21. # Prompt for yes or no answer - returns non-zero for no
  22. getyn() {
  23.         while   echo "\n$* (y/n) \c">&2
  24.         do      read yn rest
  25.                 case $yn in
  26.                 [yY])   return 0                                ;;
  27.                 [nN])   return 1                                ;;
  28.                 *)      echo "Please answer y or n" >&2         ;;
  29.                 esac
  30.         done
  31. }
  32.  
  33. # Remove temp files and exit with the status passed as argument
  34. # Usage: cleanup status
  35. #
  36. cleanup() {
  37.         trap '' 1 2 3 15
  38.         [ "$tmp" ] && rm -f $tmp*
  39.         exit $1
  40. }
  41.  
  42. # Install third party software, if necessary, and execute mkdev type program
  43. thirdparty() {
  44.         thirdanswer=
  45.         # test if _THIRDPARTY is set
  46.         [ "$_THIRDPARTY" ] && {
  47.                 while   echo "
  48. Do you have a third party driver or product to install (y/n)?  \c"
  49.                 read thirdanswer
  50.                 do      case $thirdanswer in
  51.                         y|Y)    echo "
  52. When the next menu is displayed on the screen, choose
  53. item number 4 to add a supported product.\n"
  54.                                 /etc/custom
  55.                                 break                                   ;;
  56.                         n|N)    break                                   ;;
  57.                         *)      echo "\nPlease enter y or n.\n" >&2     ;;
  58.                         esac
  59.                 done
  60.         }
  61.  
  62.         # test if _MKDEV is set
  63.         [ "$_MKDEV" ] && sh -c "_RELINK=: $_MKDEV"
  64.  
  65.         return $OK
  66. }
  67.  
  68. # Print an error messages
  69. error() {
  70.     echo "\nError $*" >&2
  71. }
  72.  
  73. # Set PERM variable used in linkchk
  74. permschk() {
  75.     cd /
  76.     if [ -f /etc/perms/extmd ]; then
  77.         PERM=/etc/perms/extmd
  78.     elif [ -f /etc/perms/inst ]; then
  79.         PERM=/etc/perms/inst
  80.     else
  81.         error "Cannot locate LINK packages permlist. 
  82. Needed to verify linkkit installation"
  83.         cleanup $FAIL
  84.     fi
  85. }
  86.  
  87. # Test to see if link kit is installed                                                     
  88. chklinkkit() {
  89.     until       fixperm -i -d LINK $PERM
  90.     do  case $? in
  91.         4)      echo "The Link Kit is not installed." >&2               ;;
  92.         5)      echo "The Link Kit is only partially installed." >&2    ;;
  93.         *)      echo "Error testing for Link Kit. Exiting."; cleanup $FAIL ;;
  94.         esac
  95.         # Not fully installed. Do so here
  96.         while   echo "Do you wish to install it now? (y/n) \c"
  97.         do      read ANSWER
  98.                 case $ANSWER in
  99.                 Y|y)    custom -o -i LINK
  100.                         break
  101.                         ;;
  102.                 N|n)    echo "Drivers cannot be installed without the Link Kit."
  103.                         cleanup $FAIL
  104.                         ;;
  105.                 *)      echo "Please answer 'y' or 'n'. \c"
  106.                         ;;
  107.                 esac
  108.         done
  109.     done
  110. }
  111.  
  112.  
  113. # main() - starting point for action in script
  114.  
  115. cd /
  116.  
  117. # Clean up and exit after signals
  118. trap "cleanup $FAIL" 1 2 3 15
  119.  
  120. permschk
  121.  
  122. # Check for link kit, since drivers cannot be installed without it
  123. chklinkkit
  124.  
  125. # if there is a third party driver or software to be installed then the
  126. # _THIRDPATY variable is set to true. In that case we want to install that
  127. # software using custom
  128.  
  129. [ "$_THIRDPARTY" ] && thirdparty
  130.  
  131. # Run install.driver for each driver selected (sets up driver-specific info)
  132. # A driver install script should be present in /tmp for each package the user
  133. # selected from custom
  134. for i in /tmp/install.*
  135. do
  136.         $i || {
  137.                     echo "\n$i script failed. Exiting ..\n"
  138.                     cleanup $FAIL
  139.             }                
  140. done
  141. rm -f /tmp/install.*
  142. cleanup $OK
  143.