clear K_VER=$(uname -r) K_FLAG=2$(echo ${K_VER} | sed -ne 's/^2\.[4]\..*/4/p')x driver_name=${1} if [ -z "${driver_name}" ]; then echo "The Linux driver supports RTL8168B and RTL8100E." echo "Usage: ./build driver_name" exit 1 elif [ \( "${driver_name}" != 'RTL8168B' \) -a \ \( "${driver_name}" != 'RTL8100E' \) ]; then echo "The Linux driver for ${driver_name} is not supported." exit 1 fi if [ "${K_FLAG}" != '24x' ]; then cat ./src/Makefile_linux26x | sed "s/RTL81[0-9][0-9][BE]/${driver_name}/g" >| ./src/Makefile_linux26x.tmp rm ./src/Makefile_linux26x mv ./src/Makefile_linux26x.tmp ./src/Makefile_linux26x fi make clean modules if [ "${K_FLAG}" = '24x' ]; then mv ./src/rtl_ethernet.o ./src/${driver_name}.o fi rtl_nic=$(lsmod | grep 'RTL81[0-9][0-9][A-Z]' | sed -e 's/\(RTL81[0-9][0-9][A-Z]\)\(.*\)/\1/g') inserted=$(lsmod | grep 'RTL81[0-9][0-9][A-Z]' | sed -e 's/\(RTL81[0-9][0-9][A-Z]\)\(.*\)\([0-9]\)/\3/g') if [ -n "${rtl_nic}" ]; then if [ "${inserted}" != '0' ]; then ifconfig eth0 down fi rmmod ${rtl_nic} fi if [ "${K_FLAG}" != '24x' ]; then insmod ./src/${driver_name}.ko else insmod ./src/${driver_name}.o fi