#!/bin/sh
###############################################################################
# Program:
# 		MOXA Linux driver installer
#	
# History:
# 2009/09/11
#
# Author:
# Ken Huang, ken.huang@moxa.com
#
# Discription:
# The script install and load the MOXA Linux driver.
#
###############################################################################

TARGET_DRIVER="mxuport"
MXVER=1.2.9

for DRIVER in $TARGET_DRIVER
do
	if lsmod | grep -q $DRIVER ; then
		echo "Found driver in system..."
		echo "Unloading driver..."
		rmmod $DRIVER
		echo "Unload driver successfully."
		echo ""
	fi
done

if make install ; then
	echo ""
	echo "Loading driver..."
	modprobe $TARGET_DRIVER
	echo "************************************************************************"
	echo " MOXA UPort 1200/1400/1600 series driver ver $MXVER loaded successfully."
	echo "************************************************************************"
fi
