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