#!/bin/bash
# $Id: eaglediag,v 1.22 2005/03/20 11:36:53 baud123 Exp $

# Copyright (C) 2004-2005 Benoit Audouard aka baud123 (baud at magic dot fr)
# 
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

# Goal :
#	diagnostic script for eagle-usb driver (formerly adiusbadsl)
# Description :
#	provide the result of several commands to diagnose problems
#       type of system, packages dependancies
#       check for modem operationnal
#	check network configuration
#	Must be run as root
# Availability :
#	see http://baud123.free.fr/eagle/eaglediag
# Documentation :
#	see http://faq.eagle-usb.org
# Todo
#	- traduire completement les commentaires en anglais
#	- verify the user that launches eaglediag : exit with help if not root
VERSION_DIAG=`head -n 2 $0|grep Id | cut -d " " --fields=4-5`



######
###                     Definition of global variables                      ###
###_________________________________________________________________________###

# date format YYYYMMDDHHmmss
TIME_STAMP=`date +"%Y""%m""%d""%H""%M""%S"`

SYSCONF_FILE=/var/lock/subsys/adiusbadsl # for service in 1.0.4e
#SYSCONF_FILE=/etc/sysconfig/adiusbadsl
#EAGLEDIR=/usr/local/eagleusb
EAGLECONF=/etc/analog/adiusbadsl.conf
EAGLE_TEST_E=0 # verify 1.0.4e version
EAGLE_STAT=showstat
MOD_EAGLE_USB=adiusbadsl

IP_FREE="213.228.0.42"
URL_FREE="www.free.fr"

# in /bin/ on Mandrake /usr/bin on Debian 
# no longer used as not always installed...
#GAWK_BIN=gawk

# Display color only if the standard output is connected to a terminal
# which understand the escape sequences which define colors.
USE_COLORS="false"
if test -t 1; then
    case $TERM in
	linux | rxvt | xterm ) USE_COLORS="true" ;;
    esac
fi

###
### english messages

OPERSTR="Modem is operational"
EAGLEDIAG_USAGE_MSG="Usage : eaglediag [-ahvmscuilo]\n"\
"\twith no parameter, only display status\n"\
"\t-a|--all\t: show everything (not log though !)\n"\
"\t-h|--help\t: this help\n"\
"\t-v|--version\t: display version\n"\
"\t-m|--make\t: for compilation problems\n"\
"\t-s|--synchro\t: when the modem does not synchronize\n"\
"\t-c|--connect\t: for connection problems (ifconfig + route)\n"\
"\t-u|--usb\t: for usb related problems (check for Latency)\n"\
"\t-i|--interrupts : to check if an IRQ is shared\n"\
"\t-d|--disk : check if dma is activated (should be)\n"\
"\t-l|--log\t: selection of /var/log/messages (sort and select what's relevant !)\n"\
"\t-n|--newbie\t: add comments for explanations about what is displayed\n"\
"\t-o|--output [file]\t: choose output file name\n"


######
###                     Definition of global functions                      ###
###_________________________________________________________________________###

evalParams() {
        while getopts "hmscuidlavno:" opt; do # t:
		        # with an argument add ":" after letter and take the argument with :
                        #t  ) TIMEOUT=$OPTARG ;;
                case $opt in
                        h  ) echo -e $EAGLEDIAG_USAGE_MSG ; exit 0 ;;
                        m  ) PB_COMPIL=1 ;;
                        s  ) PB_SYNCHRO=1 ;;
                        c  ) PB_CONNECT=1 ;;
                        u  ) PB_USB=1 ;;
                        i  ) PB_IRQ=1 ;;
                        d  ) PB_DISK=1 ;;
                        l  ) PB_MESSAGES=1 ;;
                        n  ) HELP_NEWBIE=1 ;;
			a  ) PB_COMPIL=1 ; PB_SYNCHRO=1 ; PB_CONNECT=1 ; PB_USB=1 ; PB_IRQ=1 ; PB_DISK=1 ;;
			o  ) LOG_FILE=$OPTARG ;;
                        v  ) echo $0 ${VERSION_DIAG} ; exit 1 ;;
                        \? ) echo -e $EAGLEDIAG_USAGE_MSG ; exit 1 ;;
                esac
        done
}

echoLog () {
# display to screen & into log file
# add a -n to display without "\n" at the end (result following...)
	if [ "$USE_COLORS" = "true" ]; then
		echo "$@" | tee -a ${LOG_FILE} \
		    | sed -e "s/OK/[32mOK[0m/g" -e "s/KO/[31mKO[0m/g"
	else
		echo "$@" | tee -a ${LOG_FILE}
	fi
}

echoNewbie () {
	if [ ${HELP_NEWBIE} -eq 1 ]; then
		echo "$@" | tee -a ${NEWBIE_FILE}
	fi
}

encapsToPppox() {
	case "$1" in
	    "1" | "2" ) echo pppoe ;;
	    "3" | "4" ) echo none ;;
	    "5" | "6" ) echo pppoa ;;
	esac
}
######
###                     Extract options of command line                     ###
###_________________________________________________________________________###

###
### Set default value of options

PB_COMPIL=0  # do not look at compilation problems (dependancies...)
PB_SYNCHRO=0 # do not look at synchro problems
PB_CONNECT=0 # do not give connection infos
PB_STATUS=1  # provide info on status [this test is never used...]
PB_USB=0     # no usb info
PB_IRQ=0     # no interrupts infos
PB_MESSAGES=0 # do not display any selection of /var/log/messages (even for all)
PB_DISK=0    # do not display problems with disk (hdparm test to verify that DMA is active)
HELP_NEWBIE=0 # do not display help for each command...



###
### Parse the command line and extract options

set -- "${@/#--help/-h}"
# with a parameter to the argument (for example timeout...)
# set -- "${@/#--timeout=/-t}"
# set -- "${@/#--timeout/-t}"
set -- "${@/#--make/-m}"
set -- "${@/#--synchro/-s}"
set -- "${@/#--connect/-c}"
set -- "${@/#--usb/-u}"
set -- "${@/#--interrupts/-i}"
set -- "${@/#--log/-l}"
set -- "${@/#--disk/-d}"
set -- "${@/#--version/-v}"
set -- "${@/#--all/-a}"
set -- "${@/#--newbie/-n}"
set -- "${@/#--output/-o}"

evalParams "$@"
# for debug purpose, uncomment the following line
#echo "-mscuidl" $PB_COMPIL $PB_SYNCHRO $PB_CONNECT $PB_USB $PB_IRQ $PB_DISK $PB_MESSAGES $HELP_NEWBIE

######
###                              Introspection                              ###
###_________________________________________________________________________###

# this is the only criteria I've found to identify 1.0.4e...
# this file does not exist in 1.0.5cvs nor with <=1.0.4
# well never test 1.0.4e
if [ -f /etc/eagleusb.conf ] ; then
	EAGLE_TEST_E=0
fi

# since v1.0.5pre1cvs : directory change
# hence this is my criteria to identify new version with eagle everywhere instead of adi
if [ -f /etc/eagle-usb/eagle-usb.conf ] ; then
	EAGLECONF=/etc/eagle-usb/eagle-usb.conf
	EAGLE_TEST_E=0 # do not verify 1.0.4e version
	EAGLE_STAT=eaglestat
	MOD_EAGLE_USB="eagle.usb"
fi

# GET_INFO

#CONF_EAGLE_VPI_VCI_ENCAP=`${GAWK_BIN}  -F "=" 'BEGIN { vpi=0 ; vci=0; encap=0 } /^VPI/ { vpi=$2 ; } /^VCI/ { vci=$2 } /^Encap/ { encap=$2 } /^ISP/ { isp=$2 }  END { printf("%d %d %d %s", vpi,vci,encap,isp); }' ${EAGLECONF}` 
# why doesn't '| read variable_name' does not put the displayed result in a variable ? (worked on Digital Unix)
CONF_EAGLE_VPI=`grep -E "^VPI" ${EAGLECONF} | sed -r "s/^.+=0+//g"` 
CONF_EAGLE_VCI=`grep -E "^VCI" ${EAGLECONF} | sed -r "s/^.+=0+//g"` 
CONF_EAGLE_ENCAP=`grep -E "^Encap" ${EAGLECONF} | sed -r "s/^.+=0+//g"` 
CONF_EAGLE_ISP=`grep -E "^ISP" ${EAGLECONF} | sed -r "s/^.+=//g"` 
#echo ${CONF_EAGLE_VPI_VCI_ENCAP}

PPPOX=`encapsToPppox ${CONF_EAGLE_ENCAP}`

CONF_EAGLE_VPI_VCI_ENCAP="${CONF_EAGLE_VPI} ${CONF_EAGLE_VCI} ${CONF_EAGLE_ENCAP} (${PPPOX}) ${CONF_EAGLE_ISP}" 

# Identify which version the user is running for his/her own good sake
# Mandrake and Red-Hat have rpm
RPM_EXIST=0 ## RPM detection is based on distribution, maybe a better test exists ?
APT_EXIST=0 ## APT detection based on distrib, maybe a better test exists ?
PING_WAIT="-w 5" # option for ping to stop after 5 seconds

# well well well, 2 new problems : 
# - gcc-2.95 and gcc-3.x coexist on debian systems (and others...), use eaglectrl -v (if available, to check which one has been used...)
# - kernel can be compiled with an english version, gcc display may differ depending on LOCALE :-(
# will be enhanced next time... mostly RedHat/Fedora and SuSe concerned...
#GCC_VERSION=`gcc -v 2>&1 | awk "/gcc / { print $3 }"`
# identify gcc used to compile eaglectrl (for example, for me : )
# Compiled with gcc 3.4.1 (Mandrakelinux (Alpha 3.4.1-3mdk)
GCC_VERSION=`eaglectrl -v | sed -n -e "s/Compiled with gcc//p;T;Q"`
# only keep version number... (SuSE & RedHat otherwise incorrectly triggered as compiled in english)

# do not use elif, many files may exist for one distribution
DISTRIB="generic"
DISTRIB_FILE=""
if [ -f /etc/redhat-release ] ; then
        RPM_EXIST=1
	DISTRIB="rh"
	DISTRIB_FILE=/etc/redhat-release
fi
# on Mandrake, redhat-release exist... must therefore be after red-hat (same for Suse ?)
if [ -f /etc/mandrake-release ] ; then 
	RPM_EXIST=1
	DISTRIB="mdk"
	DISTRIB_FILE=/etc/mandrake-release
fi
if [ -f /etc/gentoo-release ] ; then
	DISTRIB="gentoo"
	DISTRIB_FILE=/etc/gentoo-release
fi
if [ -f /etc/debian_version ] ; then
	APT_EXIST=1 # I do not know how to use it, nevertheless may be useful in the future ?
	DISTRIB="debian"
	DISTRIB_FILE=/etc/debian_version
	PING_WAIT="" # -w 5 option not compatible with debian...
fi
# on Fedora, redhat-release may exist... should therefore be after red-hat
if [ -f /etc/fedora-release ] ; then 
	RPM_EXIST=1
	DISTRIB="fedora"
	DISTRIB_FILE=/etc/fedora-release
fi
if [ -f /etc/slackware-version ] ; then 
	DISTRIB="slackware"
	DISTRIB_FILE=/etc/slackware-version
fi
if [ -f /etc/SuSE-version ] ; then 
	DISTRIB="SuSE"
	DISTRIB_FILE=/etc/SuSE-version
fi
if [ -f /etc/yoper-release ] ; then
	DISTRIB="yoper"
	DISTRIB_FILE=/etc/yoper-release
	PING_WAIT="" # -w 5 option not compatible with Yoper...
fi


######
###                              Initialization                             ###
###_________________________________________________________________________###

# Paths
if [ `id -u` -eq 0 ]; then
	LOG_DIRECTORY=/var/log/eagle-usb
else
	PATH=$PATH:/usr/sbin:/usr/local/sbin
	LOG_DIRECTORY=$HOME/.eagle-usb
fi

LOG_FILE=$LOG_DIRECTORY/eagle_diag_${TIME_STAMP}.txt
NEWBIE_FILE=$LOG_DIRECTORY/eagle_diag_newbie.txt

# create log directory if necessary
if [ ! -d $LOG_DIRECTORY ] ; then
	mkdir $LOG_DIRECTORY
	# make it world writable to use with sudo
	chmod 755 $LOG_DIRECTORY
fi

# an output file is specified... verify I can write
# I made all I could to avoid this... msec is sometimes around :-(
touch ${LOG_FILE}
chmod 0644 ${LOG_FILE}
echo -n >${LOG_FILE}

if [ ${HELP_NEWBIE} -eq 1 ] ; then
	touch ${NEWBIE_FILE}
	chmod 0644 ${NEWBIE_FILE}
	echo -n >${NEWBIE_FILE}
fi

######
###                           Display diagnostics                           ###
###_________________________________________________________________________###

# Start Diagnostics
echoLog "Diagnostic (${VERSION_DIAG}) driver eagle-usb ${TIME_STAMP}"
echoNewbie "## First, provide information about your system and what you used to compile"

# System Information 
echoLog "# System Information"
uname -a | tee -a ${LOG_FILE}
if [ ${DISTRIB} != "generic" ] ; then
	cat ${DISTRIB_FILE} | tee -a ${LOG_FILE}
else
	echoLog "other distrib" 
fi
cat /proc/version | tee -a ${LOG_FILE}

# gcc version begins by gcc
# verify that -v works with Red Hat, for Mandrake and Debian -v it's ok, 
# --version does not work with Debian
# Red Hat response in French does not begin with gcc (version I think... #?!@#)
echo `gcc -v 2>&1 |grep -iE "gcc " 2>&1 | tee -a ${LOG_FILE}` used : ${GCC_VERSION}
if [ ${PB_SYNCHRO} -eq 1 -o ${PB_COMPIL} -eq 1 ] ; then
	# Verify dependances of eagle-usb driver on kernel-source and other packages...
	# if a binary RPM were used, there would be no need for this
	# well... it depends on the type of connection though :-/
	echoNewbie "## not all dependances are required : it depends on the way you installed and your ISP, see FaqEagle for more details" 
	echoLog "# Dependances"
	if [ ${RPM_EXIST} -eq 1 ] ; then
		(
		rpm -q kernel-source
		rpm -q kernel-source-2.6
		rpm -q ppp 
		rpm -q dhcp-client 
		rpm -q dhcpcd 
		)  2>&1 | tee -a ${LOG_FILE} 
	elif [ ${APT_EXIST} -eq 1 ] ; then
		(
		dpkg-query --showformat='${Package} ${Version} ${Status}\n' --show ppp 
		dpkg-query --showformat='${Package} ${Version} ${Status}\n' --show dhcp-client 
		dpkg-query --showformat='${Package} ${Version} ${Status}\n' --show dhcpcd 
		) 2>&1 | tee -a ${LOG_FILE} 
	else
		# people without rpm or deb are not going to be happy...
		# give me a simple way to check what you installed ! (Gentoo ebuild ?)
		echoLog "Verify dependances on source by hand (kernel-source...)"
	fi

	echoNewbie "## this is important if you compiled the eagle-usb driver : it shows you used the appropriate kernel"
	# Another verification (which source is used ?)
	# deux verifs valent mieux qu'une (3 en comptant le uname)
	# matches linux-X.Y.Z and kernel-headers-X.Y.Z
	ls -l /usr/src/ | grep -iE "linux|kernel" 2>&1 | tee -a ${LOG_FILE}

	# first step towards intelligence for eaglediag : verify that gcc used
	# to compile eaglectrl is the same as the one used to compile the kernel
	KERNEL_COMPILED_WITH_SAME_GCC=`grep "${GCC_VERSION}" /proc/version`
	if [ "X""${KERNEL_COMPILED_WITH_SAME_GCC}" = "X" ] ; then
		echoLog "Warning : available gcc and the version used to compile the kernel differ" 
		echoLog "Advice  : that's a standard problem on debian, revert to gcc version used for kernel"  
	fi
fi # synchro / compil

if [ ${PB_SYNCHRO} -eq 1 -o ${PB_USB} -eq 1 -o ${PB_IRQ} -eq 1 ] ; then
	echoNewbie  "## lsmod shows the modules used by the driver"
	# Verify modules configuration
	# Verifie config des modules
	echoLog "# Kernel config : usb modules" 
	lsmod | grep -E "usb|hci|ppp" | tee -a ${LOG_FILE}
fi # synchro / usb

if [ ${PB_USB} -eq 1 ] ; then
	echoNewbie "## identify if your USB latency is appropriate, see FaqDiag for more information ; shows your USB configuration" 
	echoLog "# pci & usb configuration (check for latency, only keep relevant lines about USB)"
	lspci | tee -a ${LOG_FILE} # display a summary
	cat /proc/pci | tee -a ${LOG_FILE} # look for latency
	echoNewbie "## lsusb shows that your USB devices are seen, otherwise try noapic acpi=off in /etc/lilo.conf" 
	lsusb | tee -a ${LOG_FILE} # identify devices plugged in
fi # usb

if [ ${PB_IRQ} -eq 1 ] ; then
	echoNewbie "## verify that you have no IRQ shared, may lead to a problem (mostly with audio or video card)" 
	echoLog "# interruptions' affectation"
	# look for modules on the same IRQ (may conflict, mainly usb with eth)
	cat /proc/interrupts | tee -a ${LOG_FILE} 
fi # interrupts

if [ ${PB_DISK} -eq 1 ] ; then
	echoNewbie "## dma has to be OK, otherwise see FaqDiag" 
	HDD="`mount | grep 'on / ' | cut -d ' ' -f1`"
	if hdparm -d $HDD | grep -qE "using_dma.*=.*1.*(on)" ; then
	   echoLog "# disk uses dma ?        [ OK ]"
   	else
	   echoLog "# disk uses dma ?        [ KO ]"
	fi
fi # disk uses dma ?

if [ ${EAGLE_TEST_E} -eq 1 ] ; then
	# valid for 1.0.4e
	echoLog -n "# service started ? (info for 1.0.4e)  "
	if [ -f $SYSCONF_FILE ] ; then
		echoLog "[ OK ]"
	else
		echoLog "[ KO ]"
	fi
fi

echoNewbie "## an eaglediag -m is needed if module loaded KO" 
echoLog -n "# module loaded ?        " 
if lsmod | grep -qE "${MOD_EAGLE_USB}" ; then
	echoLog "[ OK ]" 
else
	echoLog "[ KO ]" 
fi

echoNewbie "## try eaglectrl -w if modem operational is KO => your modem has to synchronize, otherwise try other configuration depending on your ISP" 
echoLog -n "# modem operational ?    " 
if ${EAGLE_STAT} | grep -q "Modem is operational" ; then
	echoLog "[ OK ]" 
else
	echoLog "[ KO ]"
fi

echoNewbie "## eaglestat shows how your modem works, compulsory result : Modem is operational " 
if [ ${PB_SYNCHRO} -eq 1 ] ; then
	# provide showstat/eaglestat result (gives attenuation)
	# identify VPI/VCI in decimal
	${EAGLE_STAT} | tee -a ${LOG_FILE}
fi # synchro

# si le service est lance (faut un minimum d'effort tout de meme)
# commente : n'a plus l'air de fonctionner avec Mandrake 9.2 ?
#if [ -f $SYSCONF_FILE ] ; then
	SERVICE_CONNEXION=0 # le service de connexion est operationnel ?
	# ce serait pas mal d'avoir plus d'info que groupe/degroupe
	# maintenant ya 9telecom, les anglais, ...
	# cryptic gawk to get vpi/vci/encapsulation, lines in config files are
	# {begin of line} {keyword} {=} {value}, this gawk gets the value
	
	echoNewbie "## shows VPI / VCI / Encapsulation and shows that connection is being / has been established" 
	echoLog "# Config vpi/vci/encapsulation/isp : ${CONF_EAGLE_VPI_VCI_ENCAP}" 
	ps auxww|grep pppd|grep -v grep > /dev/null
	PPPD_ACTIVE=$?
	if [ "${PPPOX}" != "none" ] ; then
		echoLog -n "# pppd launched ?        " 
		if [ "${PPPD_ACTIVE}" = "0" ] ; then
			echoLog "[ OK ]" 
			SERVICE_CONNEXION=1
		else
			echoLog "[ KO ]"
		fi
		# ajouter tests divers lie au non degroupe
		# add tests related to "non dgroupe"
	else
		echoLog "# dhcpclient launched ?  "
		SERVICE_CONNEXION=1
		# how to test that dhcpcd or dhclient were launched ????
		# tests related to "Free degroupe"
		# pppd should not be launched
		if [ "${PPPD_ACTIVE}" = "0" ] ; then
			echoLog "# pppd should not be launched [ KO ]"
		fi
	fi
	if [ ${SERVICE_CONNEXION} -eq 1 ] ; then
		echoLog "# Service for connection [ OK ]"
	fi

	if [ ${PB_CONNECT} -eq 1 ] ; then
		echoNewbie "## confirms you received an answer with the appropriate DNS"
		# bah on fait quand meme ces tests 
		# (avec IP fixe, il ne devrait pas yavoir besoin de dhcpclient...)
		# ya des infos sur le LAN que l'utilisateur devrait cacher
		echoLog  "# /etc/resolv.conf should contain the DNS" 
		# debug : verifier que ca marche si c'est un lien
		if [ -f /etc/resolv.conf ] ; then
			cat /etc/resolv.conf | tee -a ${LOG_FILE}
		fi

		echoNewbie "## ifconfig -a shows that your interface (either ppp+ or ethX) has an IP" 
		ifconfig -a | tee -a ${LOG_FILE}

		echoNewbie "## shows that routing is correctly done (once you've got an IP)" 
		route -n | tee -a ${LOG_FILE}
	fi # connect
		
	echoNewbie "## look at result of ping IP first : if OK then you're connected, otherwise not connected or a firewall blocks your traffic (check with iptables --list) " 
	echoLog -n "# ping IP ?              " 
	# -n does not use DNS, -q quiet (), -c 1 un seul paquet envoy, 
	# -w 5 attend rponse au plus tard en 5s : non compatible debian
	#/bin/ping -n -q -c 1 -w 5 ${IP_FREE} 1>/dev/null 2>/dev/null
	/bin/ping -n -q -c 1 ${PING_WAIT} ${IP_FREE} 1>/dev/null 2>/dev/null
	if [ $? = 0 ] ; then
		echoLog "[ OK ]"
	else
		echoLog "[ KO ]"
	fi

	echoNewbie "## if the following test works for ping using DNS resolution, it confirms that you access internet, otherwise check your DNS in /etc/resolv.conf or search for clamp MSS on FaqEagle or forum"
	echoLog -n "# test DNS resolution ?  "
	#/bin/ping -n -q -c 1 -w 5 ${URL_FREE} 1>/dev/null 2>/dev/null
	/bin/ping -n -q -c 1 ${PING_WAIT} ${URL_FREE} 1>/dev/null 2>/dev/null
	if [ $? = 0 ] ; then
		echoLog "[ OK ]"
	else
		echoLog "[ KO ]"
	fi
#fi

# display a selection of /var/log/messages : beware this can be very long !!!
if [ ${PB_MESSAGES} -eq 1 ] ; then
	# would be cool to restrict to current day ? unless -all is selected ? evol !
	# or restrict from last restart (dmesg is better for this but lacks the timestamp and many messages)
	# adsl : may not be useful (part of adiusbadsl...)
	# apic|acpi : may be added in the future
	echoLog "# selection of /var/log/messages content (please sort and only keep what's relevant !)"
	grep -iE "usb|hci|adi|eagle|pci|hotplug|insmod|ppp|dhclient|dhcp|respawn" /var/log/messages | tee -a ${LOG_FILE}

fi

echoNewbie "## your IP should be obliterated (last number replaced with .xxx)" 
echo "##Complete diagnostic has been saved on ${LOG_FILE}"
echo "##Please keep only relevant data and remove personal informations."
exit 0


#***************************************************************************
# $Log: eaglediag,v $
# Revision 1.22  2005/03/20 11:36:53  baud123
# correct obsolete -2 option
#
# Revision 1.21  2005/01/16 22:02:27  Tux
# - add license header
#
# Revision 1.20  2004/12/15 22:17:08  baud123
# add copyright line + yoper distribution
#
# Revision 1.19  2004/11/28 22:26:00  mcoolive
# - improve eaglediag executed by the simple user.
#
# Revision 1.18  2004/11/04 23:22:55  mcoolive
# - fix a typo, simplify some calculations
#
# Revision 1.17  2004/11/04 22:15:11  baud123
# permit log for normal user (using sudo) & correct some comments for newbies
#
# Revision 1.16  2004/10/24 21:58:23  mcoolive
# - remove key word "function" (remove bashisme -> more sh)
# - fix one typo
# - don't use colors if eaglediag is used in a pipeline
#
# Revision 1.15  2004/10/24 00:42:13  baud123
# add color to eaglediag OK/KO
#
# Revision 1.14  2004/09/23 18:50:14  baud123
# replace == with = for string comparison
#
# Revision 1.13  2004/08/29 21:41:54  baud123
# add CR at end of dpkg-query
#
# Revision 1.12  2004/08/29 20:59:46  baud123
# many improvements, removal of gawk use, more generic test than free degroupe
#
# Revision 1.11  2004/08/18 11:54:26  mcoolive
# - fix last modifications (delete a forget `}' and add a space after one cmd)
#
# Revision 1.10  2004/08/17 22:10:29  baud123
# remove TMP_FILE + CMDECHO (not used any more)
#
# Revision 1.9  2004/08/09 22:46:29  baud123
# many cosmetic fixes from mcoolive + echoLog/Newbie
#
# Revision 1.8 2004/08/09 mcoolive
# - big cosmetic changes
#
# Revision 1.7 2004/07/25 baud123
# - add option output file + display ISP
#
# Revision 1.6 2004/05/04 baud123
# *** empty log message ***
#
# Revision 1.5 2004/05/04 baud123
# - add GPL license and newbie mode
#
# Revision 1.4 2004/03/14 baud123 
# - add hdparm test + correction for gcc version 
#   (incorrectly triggered for SuSE/RedHat)
#
# Revision 1.3 2004/02/29 baud123
# - ping does not have option -w in debian
#
# Revision 1.2 2004/01/11 baud123
# - compliant with kernel 2.6.0 (eagle_usb module instead of eagle-usb)
#
# Revision 1.1 2003/12/21 baud123
# - change log directory to /var/log/eagle-usb/
# - add version mismatch (gcc / kernel)
#
# Revision 1.0 2003/11/23 baud123
# - add parameters, add functionalities (-uali), a revamped version !
# - ajouter un filtre sur /var/log/messages 
#   (mots clefs grep -iE: pppd, usb, adi, ...)
#
# Revision 0.9 2003/10/17 baud123
# - module is eagle-usb not adiusbadsl since 1.0.5, 
# - deactivate 1.0.4e service check
# - remaining translations...
#
# Revision 0.8 2003/10/13 baud123 
# - rename script from diag_eagle_usb.sh to eaglediag
# - use tee instead of tail -f to avoid a kill in the end...
#
# Revision 0.7 2003/10/07 baud123 
# - do not rely on DEGROUPE=0 (1.0.4e specific...), 
#   choose VCI=23(Free) or 24 (Degroupe)
# - replace * with # to avoid unwanted copy/paste and rpm exist for red-hat !
#
# Revision 0.6 
# - correction anomaly eagleusb.conf => eagle-usb.conf (ballot)
#
# Revision 0.5 
# - take into account eagle-cvs and eagle-1.0.4
#
#***************************************************************************/

