home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 4 Drivers / 04-Drivers.zip / viabus.zip / 580_238.EXE / arj / UNIX / VIAIDE.TAR / tmp / init.via
Text File  |  1997-08-26  |  5KB  |  272 lines

  1. : ${OK=0} ${FAIL=1} ${STOP=10}
  2. VER=`uname -r`
  3. OSVER=`swconfig|awk -e '/SCO UNIX System V Operating Sys/ {print $7}'`
  4. HD_SPACE=/etc/conf/pack.d/hd/space.c
  5. LINKPKG=/etc/perms/inst
  6. Wd_Sdevice=/etc/conf/sdevice.d/wd
  7. Wd0_Sdevice=/etc/conf/sdevice.d/wd0
  8. Wd1_Sdevice=/etc/conf/sdevice.d/wd1
  9. Tmp_Wd=/tmp/tmpwd
  10. Tmp_Wd0=/tmp/tmpwd0
  11. Tmp_Wd1=/tmp/tmpwd1
  12. CONF=/etc/conf/cf.d
  13. PRODUCT="VIA Bus Master PCI IDE Device Driver"
  14.  
  15. # Check whether the linkpkg exists.
  16. linkpkg_check()
  17. {
  18.     if  [ ! -f $LINKPKG ] ; then
  19.         echo "Please install the LINK PACKAGE first.\n"
  20.         exit $FAIL
  21.     fi
  22. }
  23.  
  24. #Mask Default IDE Card
  25. mask_default_ide()
  26. {
  27.     
  28.     grep Y $Wd_Sdevice > /dev/null 2>&1
  29.     if [ $? -eq 0 ] ; then
  30.         sed "s/Y/N/" $Wd_Sdevice > $Tmp_Wd || { 
  31.         echo "Enable to modify the $Wd_Sdevice\n"
  32.         return $FAIL
  33.         }
  34.     fi
  35.  
  36.     grep Y $Wd0_Sdevice > /dev/null 2>&1
  37.     if [ $? -eq 0 ] ; then
  38.         sed "s/Y/N/" $Wd0_Sdevice > $Tmp_Wd0 || { 
  39.         echo "Enable to modify the $Wd0_Sdevice\n"
  40.         return $FAIL
  41.         }
  42.     fi
  43.  
  44.     grep Y $Wd1_Sdevice > /dev/null 2>&1
  45.     if [ $? -eq 0 ] ; then
  46.         sed "s/Y/N/" $Wd1_Sdevice > $Tmp_Wd1 || { 
  47.         echo "Enable to modify the $Wd1_Sdevice\n"
  48.         return $FAIL
  49.         }
  50.     fi
  51.     
  52.     trap_off    
  53.  
  54.     mv $Tmp_Wd $Wd_Sdevice > /dev/null 2>&1
  55.     mv $Tmp_Wd0 $Wd0_Sdevice > /dev/null 2>&1
  56.     mv $Tmp_Wd1 $Wd1_Sdevice > /dev/null 2>&1
  57.  
  58.     trap_on
  59.     return $OK    
  60. }
  61. #Mask Default IDE Card for OS version 5.0.0
  62. mask_default_ide_5()
  63. {
  64.     
  65.     grep Y $Wd_Sdevice > /dev/null 2>&1
  66.     if [ $? -eq 0 ] ; then
  67.         sed "s/Y/N/" $Wd_Sdevice > $Tmp_Wd || { 
  68.         echo "Enable to modify the $Wd_Sdevice\n"
  69.         return $FAIL
  70.         }
  71.     fi
  72.  
  73.     mv $Tmp_Wd $Wd_Sdevice > /dev/null 2>&1
  74.     trap_on
  75.     return $OK    
  76. }
  77.  
  78. # Add the routine entry to the "/etc/conf/pack.d/hd/space.c"
  79. add_hd_space_c()
  80. {
  81. # clear the previous setup
  82. grep vth0 $HD_SPACE > /dev/null 2>&1
  83. if [ $? -eq 0 ];then
  84. ed $HD_SPACE > /dev/null 2>&1 <<EOF
  85. /vth0
  86. .
  87. /vth0
  88. d
  89. .
  90. w
  91. EOF
  92. fi
  93.  
  94. ed $HD_SPACE > /dev/null 2>&1 <<EOF
  95. /wd0
  96. a
  97. extern int    vth0pres(), vth0open(), vth0intr(), vth0halt();
  98. .
  99. /wd0
  100. a
  101.     {vth0pres, vth0open, vth0intr, vth0halt, 1},
  102. .
  103. w
  104. EOF
  105. }
  106.  
  107. # Add the routine entry to the "/etc/conf/pack.d/hd/space.c" for OS version 5.0.0
  108. add_hd_space_c_5()
  109. {
  110. # clear the privious setup
  111. grep VTH_CNTLS $HD_SPACE > /dev/null 2>&1
  112. if [ $? -eq 0 ];then
  113. ed $HD_SPACE > /dev/null 2>&1 <<EOF
  114. /VTH_CNTLS
  115. .,.+2 d
  116. .
  117. /VTH_CNTLS
  118. .,.+2 d
  119. .
  120. w
  121. EOF
  122. fi
  123.  
  124. ed $HD_SPACE > /dev/null 2>&1 <<EOF
  125. /WD
  126. /endif
  127. .
  128. a
  129. #ifdef VTH_CNTLS
  130. extern int    vth0pres(), vth0open(), vth0close(), vth0intr(), vth0halt();
  131. #endif
  132. .
  133. /WD
  134. /endif
  135. .
  136. a
  137. #ifdef VTH_CNTLS
  138.     {vth0pres, vth0open, vth0close, vth0intr, vth0halt, 1},
  139. #endif
  140. .
  141. w
  142. EOF
  143. }
  144.  
  145. #Rebuild the kernel.
  146. build_kernel()
  147. {
  148.  
  149.     cd $CONF
  150.     getyn "You must create and install a new kernel
  151. to complete the $PRODUCT installation.
  152.  
  153. Do you wish to create a new kernel now"  ||  {
  154.  
  155.     getyn "The $PRODUCT software will not function until a
  156. new kernel is re-linked and installed.
  157. Do you wish to create a new kernel now" || {
  158.         exit $OK
  159.         }
  160.     }
  161.     echo "\nRe-linking the kernel ..." >&2
  162.     ../bin/idbuild -y || { 
  163.         echo "kernel link failed."
  164.         exit $FAIL
  165.     }
  166.     echo "
  167. The system must be re-booted for the installation to be complete
  168.  
  169. Press <Return> to continue\c"
  170.     read x
  171. }
  172.  
  173. # Turn on the trap.
  174. trap_on()  {    
  175.     trap 'echo "\nThe installation is Interrupted! Exiting ! "; cleanup 1' 1 2 3 15
  176. }
  177.  
  178. # Turn off the trap.
  179. trap_off()  {
  180.     trap '' 1 2 3 15
  181. }
  182.  
  183. # Remove temp files and exit with the status passed as argument
  184. cleanup() {
  185.     trap_off
  186.     rm -f $Tmp_Wd $Tmp_Wd0 $Tmp_Wd1 > /dev/null 2>&1
  187.     exit $1
  188. }
  189.  
  190. # Get the Yes or No answer.
  191. getyn()
  192. {
  193.     while    echo "\n$* (y/n)? \c">&2
  194.     do    read yn rest
  195.         case $yn in
  196.         [yY])    return 0             ;;
  197.         [nN])    return 1            ;;
  198.         *)    echo "Please answer y or n" >&2    ;;
  199.         esac
  200.     done
  201. }
  202.  
  203. # Main
  204. if [ "$VER" = "3.2" ]
  205. then
  206.     linkpkg_check
  207.  
  208.     cd /tmp/ID/vth
  209.     /etc/conf/bin/idcheck -p vth ; exit_code=$?
  210.     if [ $exit_code -lt 16 ] ; then 
  211.         mkdir /etc/conf/pack.d/vth
  212.         /etc/conf/bin/idinstall -a -e -k -m -s -o -p -t vth
  213.     else
  214.         /etc/conf/bin/idinstall -u -e -k -m -s -o -p -t vth
  215.     fi
  216.  
  217.     cd /tmp/ID/vth0
  218.     /etc/conf/bin/idcheck -p vth0 ; exit_code=$?
  219.     if [ $exit_code -lt 16 ] ; then 
  220.         mkdir /etc/conf/pack.d/vth0
  221.         /etc/conf/bin/idinstall -a -e -k -m -s -o -p -t vth0
  222.     else
  223.         /etc/conf/bin/idinstall -u -e -k -m -s -o -p -t vth0
  224.     fi
  225.         if [ "$OSVER" = "5.0.0Cl" ]
  226.       then
  227.        cd /etc/conf/sdevice.d
  228.        cat vth0|awk -e '/vth0/ {$5=1; $6=14;OFS="\t";print $0}'>vth0.tmp
  229.        mv vth0.tmp vth0
  230.         fi
  231.  
  232.     cd /tmp/ID/vth1
  233.     /etc/conf/bin/idcheck -p vth1 ; exit_code=$?
  234.     if [ $exit_code -lt 16 ] ; then 
  235.         mkdir /etc/conf/pack.d/vth1
  236.         /etc/conf/bin/idinstall -a -e -k -m -s -o -p -t vth1
  237.     else
  238.         /etc/conf/bin/idinstall -u -e -k -m -s -o -p -t vth1
  239.     fi
  240.         if [ "$OSVER" = "5.0.0Cl" ]
  241.       then
  242.        cd /etc/conf/sdevice.d
  243.        cat vth1|awk -e '/vth1/ {$5=1;OFS="\t";print $0}'>vth1.tmp
  244.        mv vth1.tmp vth1
  245.         fi
  246.     echo "Disable default IDE driver !"
  247.  
  248.     if [ "$OSVER" = "5.0.0Cl" ]
  249.        then
  250.        mask_default_ide_5
  251.     else
  252.        mask_default_ide
  253.     fi
  254.     echo "Disable default IDE driver successfully !\n"
  255.     echo "Change the IDE configuration file."
  256.  
  257.     if [ "$OSVER" = "5.0.0Cl" ]
  258.       then
  259.        add_hd_space_c_5
  260.     else
  261.        add_hd_space_c
  262.     fi    
  263.     echo "Change the IDE configuration file successfully !\n "
  264.     build_kernel
  265. else
  266.     echo "This device driver must be installed on the SCO UNIX upper" 
  267.     echo "\"3.2\" version.\n"
  268.     exit 
  269. fi
  270.  
  271.