#!/bin/sh

if [ -f /etc/modules.conf ]; then
   echo >> /etc/modules.conf
   if [ "`grep net-pf-31 /etc/modules.conf`" = ""  ]; then
      echo "alias net-pf-31    bluez" >> /etc/modules.conf
   fi
   if [ "`grep bt-proto-0 /etc/modules.conf`" = ""  ]; then
      echo "alias bt-proto-0   l2cap" >> /etc/modules.conf
   fi
   if [ "`grep bt-proto-2 /etc/modules.conf`" = ""  ]; then
      echo "alias bt-proto-2   sco" >> /etc/modules.conf
   fi
   if [ "`grep bt-proto-3 /etc/modules.conf`" = ""  ]; then
      echo "alias bt-proto-3   rfcomm" >> /etc/modules.conf
   fi
   if [ "`grep bt-proto-4 /etc/modules.conf`" = ""  ]; then
      echo "alias bt-proto-4   bnep" >> /etc/modules.conf
   fi
   if [ "`grep tty-ldisc-15 /etc/modules.conf`" = ""  ]; then
      echo "alias tty-ldisc-15 hci_uart" >> /etc/modules.conf
   fi
   if [ "`grep char-major-10-250 /etc/modules.conf`" = ""  ]; then
      echo "alias char-major-10-250 hci_vhci" >> /etc/modules.conf
   fi
else
   echo "alias net-pf-31    bluez" > /etc/modules.conf
   echo "alias bt-proto-0   l2cap" >> /etc/modules.conf
   echo "alias bt-proto-2   sco" >> /etc/modules.conf
   echo "alias bt-proto-3   rfcomm" >> /etc/modules.conf
   echo "alias bt-proto-4   bnep" >> /etc/modules.conf
   echo "alias tty-ldisc-15 hci_uart" >> /etc/modules.conf
   echo "alias char-major-10-250 hci_vhci" >> /etc/modules.conf
fi

/usr/bin/make_dev.bluez.sh

/sbin/depmod -a

if [ -f "/etc/pcmcia/bm3.conf" ]; then
   mv /etc/pcmcia/bm3.conf /etc/pcmcia/bm3.bak
fi

/etc/rc.d/init.d/pcmcia restart

/etc/rc.d/init.d/bluetooth start

/sbin/cardctl eject
/sbin/cardctl insert

exit 0
