home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Internet 2000 December / MICD_2000_12_NR1.iso / Dreamnet / drivery / SMC / 1211.exe / SCO / 3.X / REMOVE (.txt) < prev    next >
Microsoft Windows Help File Content  |  1997-10-26  |  9KB  |  220 lines

  1. #               (C) 1989-1990 The Santa Cruz Operation, Inc.  All Rights
  2. #               Reserved.  The user has unlimited right to use, modify
  3. #               and incorporate this code into other products provided
  4. #               it is used with SCO products and the user includes
  5. #               this notice and the associated copyright notices with
  6. #               any such application.
  7. LIB=/usr/lib/lli
  8. CONF=/etc/conf
  9. PATH=/bin:/usr/bin:/etc/:$CONF/bin:$LIB
  10. # Set possible return codes for this script
  11. OK=0;   FAIL=1; RELINK=2; DRIVERINUSE=3;
  12. # prompt the user to answer a yes no question or 'q' to quit
  13. # Usage:
  14. #       prompt_yn "Message" default
  15. prompt_yn() {
  16.         mesg=$1
  17.         default=$2
  18.         while :
  19.         do
  20.                 echo "${mesg} (y/n) [${default}] : \c"
  21.                 read result
  22.                 case $result in
  23.                 y|Y) result="Y"; return $OK;;
  24.                 n|N) result="N"; return $OK;;
  25.                 "") result=`echo $default | tr "yn" "YN"`; return $OK;;
  26.                 esac
  27.                 echo "Illegal value, please type 'y' 'n' or 'q'"
  28.         done
  29. # Fake up an mdevice and an sdevice for idcheck
  30. makedevs() {
  31.         rm -fr /tmp/dev$$
  32.         mkdir /tmp/dev$$
  33.         cd /etc/conf/cf.d
  34.         cp mdevice /tmp/dev$$
  35.         cd ../sdevice.d
  36.         cat * > /tmp/dev$$/sdevice
  37. # cleanup removes stuff and exits - if $1 = $DRIVERINUSE, exits value is $2
  38. cleanup() {
  39.         tmp=$1
  40.         if [ $tmp -ne $DRIVERINUSE ]
  41.         then
  42.                 # disallow configuring greater than board zero
  43.                 netconfigdir=/usr/lib/netconfig
  44.                 nextbd=`expr $bd + 1`
  45.                 rm ${netconfigdir}/info/${drv}${nextbd} > /dev/null 2>&1
  46.                 rm ${netconfigdir}/init/${drv}${nextbd} > /dev/null 2>&1
  47.                 rm ${netconfigdir}/remove/${drv}${nextbd} > /dev/null 2>&1
  48.         else
  49.                 tmp=$2
  50.         fi
  51.         cd /
  52.         rm -fr /tmp/dev$$
  53.         rm -fr /tmp/$base
  54.         exit $tmp
  55. system_e3A() {
  56.         # decrement the 2k block buffers for cleanliness
  57.         awk '/^NBLK2048/ {
  58.                 OLD=$2-8
  59.                 printf "%s\t%s\n",$1,OLD
  60.                 next
  61.         }
  62.         { print } ' < /etc/conf/cf.d/stune > /tmp/bog$$
  63.         mv /tmp/bog$$ /etc/conf/cf.d/stune
  64. # function to remove address conflicts in the sio driver
  65. sio_conflict() {
  66.         currdir=`pwd`
  67.         cd /etc/conf/pack.d/sio
  68.         if [ "$BIO" != "0" ]
  69.         then
  70.                 grep "/* LLI {.*$BIO" space.c > /dev/null && {
  71.                         echo "Restoring serial cards using base address 0x$BIO into link kit..."
  72.                         sed -e /"LLI.*$BIO,/s/^\/\* LLI //" space.c >/tmp/bog$$
  73.                         if [ "$base" = "tok0" ]
  74.                         then
  75.                                 sed -e /"ibm COM3/s/^\/\* LLI //" /tmp/bog$$ >/tmp/foo$$
  76.                                 mv /tmp/foo$$ /tmp/bog$$
  77.                         fi
  78.                         mv /tmp/bog$$ space.c
  79.                 }
  80.         fi
  81.         cd $currdir
  82. # function to produce the information for the System file for the token ring
  83. # if tcp is installed we remove the board from /etc/tcp and /etc/strcf
  84. cleantcp() {
  85.         driver=$1
  86.         [ -f /etc/tcp ] && {
  87.                 sed "/$driver/d" /etc/tcp > /tmp/bog$$
  88.                 cp /tmp/bog$$ /etc/tcp
  89.         }
  90.         [ -f /etc/strcf ] && {
  91.                 sed "/$driver/d" /etc/strcf > /tmp/bog$$
  92.                 cp /tmp/bog$$ /etc/strcf
  93.         }
  94.         rm -f /tmp/bog$$
  95.         sed "/$driver/d" /etc/conf/cf.d/mdevice > /tmp/bog$$
  96.         cp /tmp/bog$$ /etc/conf/cf.d/mdevice
  97.         sed "/$driver/d" /etc/conf/cf.d/sdevice > /tmp/bog$$
  98.         cp /tmp/bog$$ /etc/conf/cf.d/sdevice
  99.         rm /etc/conf/node.d/$driver
  100.         rm -r /etc/conf/pack.d/$driver
  101.         rm /etc/conf/sdevice.d/$driver
  102. # restorevector check for sio (vecs 3-4) and pa drivers (vec 7)
  103. # if these are being released by lli then let us restore them to sio or pa
  104. restorevector() {
  105.         currdir=`pwd`
  106.         cd /etc/conf/cf.d
  107.         intvector=$1
  108.         test="0"
  109.         [ "$intvector" = "3" ] && test="1"
  110.         [ "$intvector" = "4" ] && test="1"
  111.         if [ "$test" = "1" ]
  112.         then
  113.                 prompt_yn "Restore vector $intvector to sio driver" y
  114.                 [ "$result" = "Y" ] && {
  115.                         echo "Restoring vector $intvector to sio driver"
  116.                         siomajor=`./configure -j sio`
  117.                         ./configure -m $siomajor -c -v $intvector -a -Y
  118.                         return $OK
  119.                 }
  120.         fi
  121.         test="0"
  122.         [ "$intvector" = "7" ] && test="1"
  123.         if [ "$test" = "1" ]
  124.         then
  125.                 prompt_yn "Restore vector $intvector to pa driver" y
  126.                 [ "$result" = "Y" ] && {
  127.                         echo "Restoring vector $intvector to pa driver"
  128.                         pamajor=`./configure -j pa`
  129.                         ./configure -m $pamajor -c -v $intvector -a -Y
  130.                         return $OK
  131.                 }
  132.         fi
  133.         return $OK
  134. # main()
  135. # get the name of the init script being run, since one script
  136. # is used for multiple drivers; get the number at the end of the
  137. # script's name
  138. if [ $# -gt 1 ]
  139.         name_below=$1; if_below=$2
  140.         name_above=$3; if_above=$4
  141. base=`basename $0`
  142. drv=`echo $base | sed -e 's/[0-9]*$//`
  143. bd=`expr $base : '.*\(.\)'`
  144. case $drv in
  145. r7e) PREFIX="r7e";;
  146. *) echo "ERROR: Unknown LLI driver being configured ($name$bd)";
  147.         cleanup $FAIL;
  148.         ;;
  149. echo "NODE=/etc/conf/node.d/$base" >/tmp/$base.src
  150. chmod 777 /tmp/$base.src
  151. # check to see if the driver is already in the kernel link-kit so we can
  152. # either add it or update it later on
  153. makedevs
  154. idcheck -p $base
  155. if [ $? -gt 16 ]
  156.         installed="TRUE"
  157.         installed="FALSE"
  158. if [ "$installed" = "FALSE" ]
  159.         cleanup $OK
  160. # Check and Manage our internal chains file.
  161. # if our board (base) is not in the chain then we always remove the board
  162. # if our board is in the chain then we check for the chain and remove it.
  163. # if after our chain is removed from the chains file the board is still there
  164. #    then we do not remove it.
  165. chains=/usr/lib/lli/chains
  166. chain=$base:$name_above
  167. if grep $base: $chains > /dev/null 2>& 1
  168.         grep $chain $chains > /dev/null 2>& 1 || {
  169.                 cleanup $OK
  170.         }
  171.         # remove our chain
  172.         awk '{
  173.                 if ($1 == CHAIN && found != 1) {
  174.                         found = 1
  175.                         next
  176.                 }
  177.                 print $0
  178.         }' CHAIN=$chain < $chains > /tmp/bog$$
  179.         cp /tmp/bog$$ $chains
  180.         rm -f /tmp/bog$$
  181.         # Check if it is there in another chain
  182.         grep $base: $chains > /dev/null 2>& 1 && {
  183.                 cleanup $DRIVERINUSE $OK
  184.         }
  185.         cleanup $OK
  186. echo "Removing $base..."
  187. # Check if we are board zero that no other boards of this type are configured
  188. [ "$bd" -eq "0" ] && {
  189.         grep ${drv}[1-3] $chains > /dev/null 2>& 1 && {
  190.                 echo "Warning, You are removing board 0 before other boards"
  191.                 echo "You must remove the other $drv boards next"
  192.                 echo "or your link-kit will be left in an invalid state"
  193.         }
  194. # Do board dependent processing
  195. case $drv in
  196.         e3A)    system_e3A $bd;;
  197. #if [ $bd -gt 0 ]
  198. #then
  199. #       idinstall -d -e $base
  200. #       cleanup $RELINK
  201. # get the interrupt vector for the board that we are removing
  202. cd /etc/conf/sdevice.d
  203. ivec=`awk '{ if ( $1 != "*" ) print $6 }' < $base`
  204. BIO=`awk '{ if ( $1 != "*" ) print $7 }' < $base`
  205. cd /tmp; rm -rf $base
  206. mkdir $base; cd $base
  207. echo "${base}\tN\t1\t5\t1\t9\t0\t0\t0\t0" >System
  208. if [ $bd -gt 0 ]
  209.         echo "$base     -       iScH    $PREFIX$bd      0       0       1       256     -1" >./Master
  210.         cp $LIB/${drv}/Master ./Master
  211. idinstall -u -e -s -m $base
  212. # restore sio space.c file
  213. sio_conflict
  214. cleantcp $base
  215. restorevector $ivec
  216. # Check to see if driver for next board is configured
  217. grep ${drv}`expr ${bd} + 1`: $chains > /dev/null 2>& 1 && {
  218.         cleanup $DRIVERINUSE $RELINK
  219. cleanup $RELINK
  220.