#!/bin/sh
#
# eciadsl_check.sh
#
# (c) 2004-02-23 by FlashCode <flashcode@flashtux.org>
#
# This script returns many info about process, modules, files...
# It is useful to run it when connection is down without any reason.
# Check that there is no confidential info (password, ...) in
# /tmp/eciadsl_check.txt, and then send this file to:
#   FlashCode <flashcode@flashtux.org>
#

if [ $UID -ne 0 ]; then
    echo -e "Sorry, this script must be run as root!"
    exit 1
fi

FILE=/tmp/eciadsl_check.txt

echo -e "*** This file was created by eciadsl_check.sh script on $(date) ***" >$FILE

echo "Writing uname -a output..."
echo -e "\n\n=== uname -a output:\n" >>$FILE
uname -a >>$FILE

echo "Writing ifconfig output..."
echo -e "\n\n=== ifconfig output:\n" >>$FILE
ifconfig >>$FILE

echo "Writing route output..."
echo -e "\n\n=== route output:\n" >>$FILE
route -n >>$FILE

echo "Writing ping 'www.yahoo.com' output..."
echo -e "\n\n=== ping 'www.yahoo.com' output:\n" >>$FILE
ping -c 3 www.yahoo.com >>$FILE

echo "Writing ping '216.109.118.74' output..."
echo -e "\n\n=== ping '216.109.118.74' output:\n" >>$FILE
ping -c 3 216.109.118.74 >>$FILE

echo "Writing process..."
echo -e "\n\n=== Running process:\n" >>$FILE
ps ax >>$FILE

echo "Writing modules..."
echo -e "\n\n=== Loaded modules:\n" >>$FILE
lsmod >>$FILE

echo "Writing EciAdsl config..."
echo -e "\n\n=== EciAdsl config (except user & pwd): \n" >>$FILE
grep -v "PASSWD" /etc/eciadsl/eciadsl.conf | grep -v "USER" >>$FILE

echo "Writing DNS servers..."
echo -e "\n\n=== DNS servers: \n" >>$FILE
cat /etc/resolv.conf >>$FILE

echo "Writing PCI devices..."
echo -e "\n\n=== PCI devices: \n" >>$FILE
lspci -vv >>$FILE

echo "Writing USB devices..."
echo -e "\n\n=== USB devices: \n" >>$FILE
cat /proc/bus/usb/devices >>$FILE

echo "Writing end of /var/log/messages..."
echo -e "\n\n=== End of system /var/log/messages: \n" >>$FILE
tail --lines=1000 /var/log/messages >>$FILE

if [ -f /var/log/syslog ]; then
    echo "Writing end of /var/log/syslog..."
    echo -e "\n\n=== End of system /var/log/syslog: \n" >>$FILE
    tail --lines=1000 /var/log/syslog >>$FILE
fi

echo -e "\n*** END OF FILE ***\n" >>$FILE

echo ""
echo "=== All done!"
echo "=== Check that there is no confidential info (password, ...) in /tmp/eciadsl_check.txt"
echo "=== and then send this file to: flashcode@flashtux.org"
