#!/bin/sh

echo ""
echo "-----------------------------------------------------------------" 
echo "Adaptec Cogent eMaster+ (10/100) PCI Fast Ethernet Uninstallation"
echo "-----------------------------------------------------------------" 
echo ""

echo "ADAPTEC: Pl. Enter the ADAPTER you want to UNINSTALL"
echo ""
echo "         1. Adaptec Cogent ANA-6911 PCI EM110"
echo "         2. Adaptec Cogent ANA-6944 PCI EM440 (4 ports)"
echo ""
echo -n "Your Choice (1 or 2) : "

read card

echo ""

if test $card = "1"
then

# ------------------------ EM110 UNINSTALLATION ---------------------------

  echo "ADAPTEC: Uninstalling Adaptec Cogent ANA-6911 PCI EM110 ..."

  echo "ADAPTEC: Running idinstall ..."
  /etc/conf/bin/idinstall -d EMPCI

  if test -f "/etc/rc2.d/S24EMPCI110"
  then
    /bin/rm /etc/rc2.d/S24EMPCI110
  fi

  echo "ADAPTEC: Running netinfo ..."
  /usr/sbin/netinfo -r -d EMPCI_0 

  echo "ADAPTEC: Updating /etc/confnet.d/inet/interface ..."
  /bin/cat /etc/confnet.d/inet/interface | /bin/sed -e '/EMPCI/d' > /tmp/EmPcI.tMp
  /bin/mv /tmp/EmPcI.tMp /etc/confnet.d/inet/interface

  echo ""
  echo "ADAPTEC: ***  EM110 has been SUCCESSfully REMOVED  ***"
  echo ""
  echo "-----------------------------------------------------------------"
  echo ""
 
  exit 0

else

  if test $card = "2"
  then

# ------------------------ EM110 UNINSTALLATION ---------------------------

    echo "ADAPTEC: Uninstalling Adaptec Cogent ANA-6911 PCI EM440 ..."

    echo "ADAPTEC: Running idinstall ..."
    /etc/conf/bin/idinstall -d EMPCI

    if test -f "/etc/rc2.d/S24EMPCI440"
    then
      /bin/rm /etc/rc2.d/S24EMPCI440
    fi

    echo "ADAPTEC: Running netinfo ..."
    /usr/sbin/netinfo -r -d EMPCI_0 
    /usr/sbin/netinfo -r -d EMPCI_1 
    /usr/sbin/netinfo -r -d EMPCI_2 
    /usr/sbin/netinfo -r -d EMPCI_3 

    echo "ADAPTEC: Updating /etc/confnet.d/inet/interface ..."
    /bin/cat /etc/confnet.d/inet/interface | /bin/sed -e '/EMPCI/d' > /tmp/EmPcI.tMp
    /bin/mv /tmp/EmPcI.tMp /etc/confnet.d/inet/interface

    echo ""
    echo "ADAPTEC: ***  EM440 has been SUCCESSfully REMOVED  ***"
    echo ""
    echo "-----------------------------------------------------------------"
    echo ""

    exit 0

  else

    echo "ADAPTEC: ERROR: Invalid choice, Try again"
    echo "ADAPTEC: ***  UNINSTALLATION FAILED  ***"
    echo ""
    echo "-----------------------------------------------------------------"
    echo ""

    exit 0

  fi

fi

