home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1999 March B / SCO_CASTOR4RRT.iso / nics / install / preremove < prev    next >
Text File  |  1998-08-19  |  3KB  |  117 lines

  1. #ident    "@(#)preremove    20.1"
  2.  
  3. exec 2>/tmp/remove.err
  4. DEBUG=on
  5. REBUILD_FLAG=false
  6.  
  7. [ -n "$DEBUG" ] && set -x
  8.  
  9. CHAINS="`/usr/sbin/netcfg -s`"
  10. SCHAINS="`echo $CHAINS | sed -e s///g`"
  11. [ "$SCHAINS" ] && {
  12.     echo ""
  13.     echo "Please use netcfg to deconfigure the following before removing nics:"
  14.     echo "$CHAINS\n"
  15.     exit 1
  16. }
  17.  
  18. if [ "$RANDOM" = "$RANDOM" ]
  19. then
  20.         exec /usr/bin/xksh $0 $*
  21. fi
  22.  
  23. LOCALE=${LC_ALL:-${LC_MESSAGES:-${LANG:-C}}}
  24. MENUDIR=/etc/inst/nics/drivers
  25. MENUDIR2=/etc/inst/nd/mdi
  26. NETINFO=/usr/sbin/netinfo
  27.  
  28. cd $MENUDIR
  29. # change to new scheme - N
  30. OLDDRIVER_LIST=`for i in */*.bcfg
  31. do
  32.     ( . ./$i ; echo $DRIVER_NAME )
  33. done | sort -u`
  34.  
  35. cd $MENUDIR2
  36. # change to new scheme - N
  37. NEWDRIVER_LIST=`for i in */*.bcfg
  38. do
  39.     ( . ./$i ; echo $DRIVER_NAME )
  40. done | sort -u`
  41.  
  42. ODI_MODS="lsl msm ethtsm toktsm odisr fdditsm"
  43. DLPI_MODS="dlpi dlpibase"
  44.  
  45. # must do the following for all hardware drivers installed
  46. for DRIVER_NAME in $OLDDRIVER_LIST $NEWDRIVER_LIST
  47. do
  48.  
  49.     [ -f /etc/conf/mdevice.d/$DRIVER_NAME ] && {
  50.         # De-configure the network device.  Treat as both ODI/DLPI, and
  51.         # as MDI driver.  Obviously only one will work.
  52.         #
  53.         # note the next lines will only work if driver type is ODI/DLPI
  54.         /etc/confnet.d/configure -r -d ${DRIVER_NAME}_0 > /dev/null
  55.         /etc/confnet.d/configure -r -d ${DRIVER_NAME}_1 > /dev/null
  56.         /etc/confnet.d/configure -r -d ${DRIVER_NAME}_2 > /dev/null
  57.         /etc/confnet.d/configure -r -d ${DRIVER_NAME}_3 > /dev/null
  58.  
  59.         # we only support up to ODI/DLPI 4 devices so remove any that
  60.         # might exist from the netdrivers file
  61.         # Likewise, this will only work if driver type is ODI/DLPI
  62.         for i in 0 1 2 3
  63.         do
  64.             ${NETINFO} -r -d ${DRIVER_NAME}_$i
  65.         done
  66.  
  67.         # now do the same thing, treating the device as if it's
  68.         # an MDI driver (through netX)
  69.         # we can have more netX devices; try up to 20
  70.         for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
  71.         do
  72.             /etc/confnet.d/configure -r -d net${i} > /dev/null
  73.             ${NETINFO} -r -d net${i} >/dev/null 2>&1
  74.         done
  75.  
  76.     }
  77.  
  78. done > /dev/null 2>&1
  79.  
  80. # stop the dlpi daemon
  81. /etc/nd stop
  82.  
  83. # must do the following for all drivers installed
  84. for DRIVER_NAME in $OLDDRIVER_LIST $NEWDRIVER_LIST $ODI_MODS $DLPI_MODS
  85. do
  86.     [ -f /etc/conf/mdevice.d/$DRIVER_NAME ] && {
  87.         # Remove the driver
  88.         /etc/conf/bin/idinstall -d $DRIVER_NAME
  89.  
  90.         # Unload the driver
  91.         modadmin -U $DRIVER_NAME
  92.  
  93.         # remove mod.d too as postinstall scripts looks for these.
  94.         rm -f /etc/conf/mod.d/$DRIVER_NAME > /dev/null 2>&1
  95.     }
  96.  
  97. done > /dev/null 2>&1
  98.  
  99. # remove odimem driver & rebuild kernel.  it will normally be present in
  100. # the link kit as the postinstall script put it there (multiple times)
  101. [ -f /etc/conf/mdevice.d/odimem ] && {
  102.     # we know odimem is $static courtesy of our postinstall script so
  103.     # no need to try and unload it.
  104.     /etc/conf/bin/idinstall -d odimem >&2
  105.     /etc/conf/bin/idbuild -B
  106.     [ "$?" = 0 ] && REBUILD_FLAG=true
  107. }
  108.  
  109. # Unregister from SCOadmin
  110. [ -f /usr/bin/scoadmin ] && {
  111. /usr/bin/scoadmin -P Networking -d "netcfg.obj"
  112. }
  113.  
  114. # rm -rf /tmp/remove.err
  115.  
  116. $REBUILD_FLAG && exit 10 || exit 0
  117.