#!/bin/bash
MODEL=
PHYSICAL=
LOGICAL=
DIST=
LINUX=
PMUSB=
PMUSBID=
LINUXUSB=
USBDRV=


#for name in a b c d ; do
#	if [ -f /proc/ide/hd$name/model ]; then
#		PHYSICAL=`cat /proc/ide/hd$name/geometry | grep physical | sed 's/physical     //g'`
#		LOGICAL=`cat /proc/ide/hd$name/geometry | grep logical | sed 's/logical     //g'`
#		echo -e $CR_RED"hd$name: $CR_CYAN`cat /proc/ide/hd$name/model `  $CR_GREEN$[`cat #/proc/ide/hd$name/capacity`/2048] MB $CR_YELLOW$PHYSICAL$CR_MAGENTA$LOGICAL$CR_NORMAL"
#	fi
#done

# get distribution
if [ -f /etc/issue.net ]; then
    DIST=`cat /etc/issue.net | grep "Red Hat"`
    if [ "$DIST" = "" ]; then
        DIST=`cat /etc/issue.net | grep Fedora`
    fi
fi

# Linux kernel version
LINUX=`uname -srm`

# X Server version
XFREE86=`xdpyinfo | grep 'XFree86 version'`
if [ "$XFREE86" = "" ]; then
    XFREE86=`rpm -qf /usr/X11R6/lib/libX11.so.6`
    if [ "$XFREE86" = "" ]; then
        XFREE86=N/A
    fi
fi

# Serial port
if [ -f /var/log/dmesg ]; then
    COMPORT=`cat /var/log/dmesg | grep ttyS`
fi


# USB

if [ -f /proc/bus/usb/devices ]; then
    LINUXUSB=`cat /proc/bus/usb/devices | grep Manufacturer=Dialogue | sed 's/Manufacturer=//g'`
    if [ "$LINUXUSB" = "" ]; then
        LINUXUSB=`cat /proc/bus/usb/devices | grep Manufacturer=DIALOGUE | sed 's/Manufacturer=//g'`
    fi

    PMUSB=`cat /proc/bus/usb/devices | grep Product=PenMount | sed 's/Product=//g'`

    PMUSBID=`cat /proc/bus/usb/devices | grep 'Vendor=14e1 ProdID=5000' | sed 's/P:  //g'`
    if [ "$PMUSBID" = "" ]; then
        PMUSBID=`cat /proc/bus/usb/devices | grep 'Vendor=1204 ProdID=9998' | sed 's/P:  //g'`
    fi
    if [ "$PMUSBID" = "" ]; then
        PMUSBID=`cat /proc/bus/usb/devices | grep 'Vendor=14e1 ProdID=6000' | sed 's/P:  //g'`
    fi
    if [ "$PMUSBID" = "" ]; then
        PMUSBID=N/A
    fi

fi

echo -e "\n"
echo -e "Linux Distributions : "
echo -e "$DIST"
echo -e "\n"

echo -e "Kernel version : "
echo -e "$LINUX"
echo -e "\n"

echo -e "X server version : "
echo -e "$XFREE86"
echo -e "\n"


echo -e "CPU Info : "
if [ -f /proc/cpuinfo ]; then
    cat /proc/cpuinfo
fi


echo -e "Interrupts : "
if [ -f /proc/interrupts ]; then
    cat /proc/interrupts
fi

echo -e "ioports : "
if [ -f /proc/ioports ]; then
    cat /proc/ioports | grep serial
fi

echo -e "Serial Port : "
echo -e "dmesg->"
if [ -f /var/log/dmesg ]; then
	dmesg | grep ttyS
fi
echo -e "/proc/devices->"
if [ -f /proc/devices ]; then
	cat /proc/devices | grep ttyS
fi
echo -e "/proc/tty/drivers->"
if [ -f /proc/tty/drivers ]; then
	cat /proc/tty/drivers | grep serial
fi
echo -e "setserial (COM1)->"
setserial -a /dev/ttyS0
echo -e "setserial (COM2)->"
setserial -a /dev/ttyS1
echo -e "setserial (COM3)->"
setserial -a /dev/ttyS2
echo -e "setserial (COM4)->"
setserial -a /dev/ttyS3
echo -e "\n"


echo -e "USB :"
echo -e "PenMount->"
echo -e "$LINUXUSB $PMUSB $PMUSBID"
echo -e "\n"

echo -e "dmesg->"
if [ -f /var/log/dmesg ]; then
	dmesg | grep usb
fi
echo -e "\n"

echo -e "USB Device->"
if [ -f /proc/bus/usb/devices ]; then
    cat /proc/bus/usb/devices
fi
echo -e "\n"

echo -e "USB Driver->"
if [ -f /proc/bus/usb/drivers ]; then
    cat /proc/bus/usb/drivers
fi
echo -e "\n"

echo -e "Linux kernel module->"
lsmod
echo -e "\n"

echo -e "List USB->"
lsusb
echo -e "\n"




