#!/bin/sh

#**********************************************************************************
# Copyright (c) 1999-2004, Intel Corporation 
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without 
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, 
# this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation 
# and/or other materials provided with the distribution.
#
# 3. Neither the name of Intel Corporation nor the names of its contributors 
# may be used to endorse or promote products derived from this software 
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
#
#***********************************************************************************
#
# Hacked by <Karentech80@Yahoo.com> for Knoppix v3.7  
# Copyright 2005 <Karentech80@Yahoo.com> all rights reserved
#
#**********************************************************************************
KERNVER=`cat /proc/version | awk "{print \\$3}"`
echo running kernel $KERNVER

if [ ${BUILD_ROOT} ]
then
      KERNELVER=`cat ${KERNEL_SOURCE}/include/linux/version.h |grep UTS_RELEASE | awk ' { print $3 } ' | awk -F\" ' { print $2 } '`
      CharModDir=${BUILD_ROOT}/lib/modules/${KERNVER}/kernel/drivers/char
      echo Target kernel version is $KERNELVER
else
case $KERNVER in
   2.4*)
      CharModDir=/ramdisk/lib/modules/${KERNVER}/kernel/drivers/char
      ;;
   2.6*)
      CharModDir=/ramdisk/lib/modules/${KERNVER}/kernel/drivers/char
      ;;
   *)
      echo "unsupported kernel version. 2.4.x and 2.6.x are supported"
      exit 1
      ;;
esac
fi


   if [ -a ./hamregistry.bin ]; then
   {
      mv -f /etc/hamregistry.bin /ramdisk/etc/hamregistry.bak
      cp ./hamregistry.bin /ramdisk/etc/hamregistry.bin
   }
   else
   {
      rm -f /etc/hamregistry.bin
   }
   fi
   echo installing unknown distribution hamregistry,  used for persistant storage
   install -o root -g root -m 110 hamregistry /ramdisk/usr/sbin
   echo installing Intel536 driver
case $KERNVER in
   2.4*)
      install -o root -g root -m 664 Intel536.o ${CharModDir}/Intel536.o || exit 1
      ;;
   2.6*)
      install -o root -g root -m 664 Intel536.ko ${CharModDir}/Intel536.ko || exit 1
      ;;
esac

   echo unknown distribution. no boot scripts installed
   exit 1
}
fi
echo starting module and utilities
depmod -a
/bin/bash Intel536_boot restart
echo done
