#!/bin/sh

LOG=/tmp/modprobe.log
ERR=/tmp/modprobe.err

########################################
### Loading the lirc modules in case you have a Hauppauge TV card...
### (in the future this should support more models...)
###############
if `lsmod | grep -q bttv` ; then
### net is needed by lircd
  modprobe af_packet >> $LOG 2>> $ERR
  modprobe unix      >> $LOG 2>> $ERR

  modprobe lirc_dev    >> $LOG 2>> $ERR
  modprobe lirc_i2c    >> $LOG 2>> $ERR
  lircd -d /dev/lirc/0 >> $LOG 2>> $ERR
else
  ### net is needed by lircd
  modprobe af_packet >> $LOG 2>> $ERR
  modprobe unix      >> $LOG 2>> $ERR

  mknod /dev/lirc c 61 0;
  if [ -e /dev/lirc ] ; then
    setserial /dev/ttyS0 uart none
    modprobe lirc_serial >> $LOG 2>> $ERR
    lircd -d /dev/lirc
  else
    rmmod lirc_serial
    rmmod af_packet
    rmmod unix
  fi 
fi

