#!/bin/bash # # Copyright (c) 2012 # # Authors: Wild Man, Krytarik # Helpers: chili555 # # This script gathers the infos necessary for troubleshooting a wireless # connection and saves them in a text file, wrapping it in an archive if it # exceeds the size limit of 19.5 kB for .txt files on the Ubuntu Forums. # ############################################################################ # # 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 3 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, see . # FILEBASE="wireless-info" MODMATCHES="(air|ar5|ath|carl|at7|iwl|ipw|rt(2|3|5|6|7)|rtl|r(818|871)|8192(cu|du)|ssb|wl|b43|bcma|brcm|eth1|ndis|wlan0|firm|etwork)[^[:punct:] ]*" exec 3>&1 4>&2 exec 1> $FILEBASE.txt 2> /dev/null if [ "$?" != "0" ]; then printf "\nCannot write output file, aborting.\n\n" exit 1 fi printf "\n########## wireless info START ##########\n" printf "\n##### release #####\n\n" lsb_release -idrc printf "\n##### kernel #####\n\n" uname -a printf "\n##### lspci #####\n\n" lspci -nnk | grep -iA2 net | sed 's/^--$//' printf "\n##### lsusb #####\n\n" lsusb printf "\n##### PCMCIA Card Info #####\n\n" pccardctl info printf "\n##### rfkill #####\n\n" rfkill list all printf "\n##### iw reg get #####\n\n" iw reg get printf "\n##### interfaces #####\n\n" sed 's/wpa-psk [[:graph:]]\+/wpa-psk /' /etc/network/interfaces printf "\n##### iwconfig #####\n\n" iwconfig printf "\n##### route #####\n\n" route -n printf "\n##### resolv.conf #####\n\n" grep -v '^#' /etc/resolv.conf printf "\n##### nm-tool #####\n" nm-tool printf "\n##### NetworkManager.state #####\n\n" cat -s /var/lib/NetworkManager/NetworkManager.state printf "\n##### NetworkManager.conf #####\n\n" grep -v '^#' /etc/NetworkManager/NetworkManager.conf if [ -f /etc/NetworkManager/nm-system-settings.conf ]; then printf "nm-system-settings.conf (used up to 10.04):\n" grep -v '^#' /etc/NetworkManager/nm-system-settings.conf fi printf "\n##### iwlist #####\n\n" if [ -t 0 ]; then sudo iwlist scan || echo "Aquiring of root rights failed." elif [ -x /usr/bin/gksudo ]; then gksudo iwlist scan || echo "Aquiring of root rights failed." elif [ -x /usr/bin/kdesudo ]; then kdesudo iwlist scan || echo "Aquiring of root rights failed." else echo "No way to aquire root rights found." fi printf "\n##### iwlist channel #####\n\n" iwlist chan printf "\n##### lsmod #####\n\n" lsmod | egrep "(^|[[:punct:] ])${MODMATCHES}([[:punct:] ]|$)" printf "\n##### modinfo #####\n\n" MODULNAMES=$(lsmod | egrep "^$MODMATCHES" | awk '{print $1}') for MODULE in $MODULNAMES; do modinfo $MODULE echo done printf "\n##### modules #####\n\n" grep -v '^#' /etc/modules printf "\n##### blacklist #####\n" for CONFFILE in /etc/modprobe.d/*.conf; do if [[ -n $(egrep -v '/etc/modprobe.d/(alsa-base|blacklist-(firewire|framebuffer|modem|oss|watchdog)|fglrx|nvidia)' <<< $CONFFILE) ]]; then BLACKLIST=$(grep '^blacklist' $CONFFILE) if [ -n "$BLACKLIST" ]; then printf "\n[%s]\n%s\n" $CONFFILE "$BLACKLIST" fi fi done printf "\n##### udev rules #####\n" egrep '^(#.*device|[^#]|$)' /etc/udev/rules.d/70-persistent-net.rules printf "\n##### dmesg #####\n\n" dmesg | egrep "[[:punct:] ]${MODMATCHES}[[:punct:] ]" printf "\n########## wireless info END ############\n\n" exec 1>&3 3>&- exec 2>&4 4>&- RESULTS=$(cat -s $FILEBASE.txt) sed 's/\([[:alnum:]][[:alnum:]]:\)\{5\}[[:alnum:]][[:alnum:]]//' <<< "$RESULTS" > $FILEBASE.txt if [ $(stat -c %s $FILEBASE.txt) -gt 19968 ]; then tar -czf $FILEBASE.tar.gz $FILEBASE.txt rm $FILEBASE.txt printf "\nResults archived in \"%s.tar.gz\", as they exceed the 19.5 kB size limit for .txt files on the Ubuntu Forums.\n\n" "$FILEBASE" else printf "\nResults saved in \"%s.txt\".\n\n" "$FILEBASE" fi