aboutsummaryrefslogtreecommitdiffstats
path: root/wireless-info
diff options
context:
space:
mode:
authorLibravatar UbuntuForumsCouncil <ubuntu-forums-council@lists.ubuntu.com>2015-05-02 16:55:13 +0100
committerLibravatar UbuntuForumsCouncil <ubuntu-forums-council@lists.ubuntu.com>2015-05-02 16:55:13 +0100
commit489181a67264498c34e9d1a5cf699c8df6c5b04f (patch)
treed239e9a1131825f0cf9846ebf8032afc6b139b9c /wireless-info
downloadwireless-info-489181a67264498c34e9d1a5cf699c8df6c5b04f.tar.bz2
wireless-info-489181a67264498c34e9d1a5cf699c8df6c5b04f.tar.xz
wireless-info-489181a67264498c34e9d1a5cf699c8df6c5b04f.tar.zst
Adding README file and wireless-info script.
Diffstat (limited to 'wireless-info')
-rw-r--r--wireless-info386
1 files changed, 386 insertions, 0 deletions
diff --git a/wireless-info b/wireless-info
new file mode 100644
index 0000000..c223a3f
--- /dev/null
+++ b/wireless-info
@@ -0,0 +1,386 @@
+#!/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 19.5 kB size limit for ".txt" attachments 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 <http://www.gnu.org/licenses/>.
+#
+
+SCRIPTDATE="2015-04-30 19:23 +0200"
+FILEBASE="wireless-info"
+OUTPUTDIR="$PWD"
+OUTPUTDIRFB="/tmp"
+
+MODMATCHES="(air|ar5|at7|ath[^3]?|b43|bcma|brcm|carl|ipw|iwl|ndis|r(818|8192[eu]|871|92su)|rt[23567]|rtl|ssb|wl|(cfg|mac)80211)"
+LSMODMATCHES="(wmi|(dell|ideapad)[-_]laptop)"
+DMESGMATCHES="(wlan[0-9]|eth[1-9]|firmware|[nN]etwork)"
+NMPROFMATCHES="\(\[connection\]\|id=\|type=\|permissions=\|autoconnect=\|\[802-11-wireless\]\|\[wifi\]\|ssid=\|bssid=\|mac-address\(-blacklist\)\?=\|mtu=\|\[802-1x\]\|[[:graph:]]*ca-certs\?=\|\[ipv[46]\]\|method=\)"
+
+DMESGEXCL="apparmor|(cfg|mac)80211"
+MODINFOEXCL="alias"
+MODPROBEXCL="(alsa-base|blacklist-(firewire|framebuffer|modem|oss|watchdog)|fglrx|nvidia|fbdev|bumblebee)"
+PMUTILSEXCL="/etc/pm/(power.d/(95hdparm-apm|intel-audio-powersave|sata_alpm)|sleep.d/(10_grub-common|10_unattended-upgrades.*|novatel_3g.*))"
+
+export LANG="en_US.UTF-8"
+export LANGUAGE="en_US:en"
+export LC_ALL="en_US.UTF-8"
+
+if [ -t 0 ]; then
+ DIALOGAPP="terminal"
+ DIALOGBREAK=" "
+ TERMOUT="yes"
+elif [ -x /usr/bin/zenity ]; then
+ DIALOGAPP="zenity"
+ DIALOGBREAK="\n"
+elif [ -x /usr/bin/kdialog ]; then
+ DIALOGAPP="kdialog"
+ DIALOGBREAK="\n"
+else
+ exit 1
+fi
+
+if [ -t 0 ]; then
+ SUDO="sudo"
+elif [ -x /usr/bin/pkexec ]; then
+ SUDO="pkexec"
+elif [ -x /usr/bin/gksudo ]; then
+ SUDO="gksudo"
+ GKSUDO="yes"
+elif [ -x /usr/bin/kdesudo ]; then
+ SUDO="kdesudo"
+ KDESUDO="yes"
+ KDESUDOCMT=" needs administrative privileges. Please enter your password."
+fi
+
+dialog_info () {
+ case $DIALOGAPP in
+ terminal)
+ printf "%b\n" "$1"
+ ;;
+ zenity)
+ zenity --info --text="$1"
+ ;;
+ kdialog)
+ kdialog --msgbox "$1"
+ ;;
+ esac
+}
+
+dialog_error () {
+ case $DIALOGAPP in
+ terminal)
+ printf "%b\n" "$1" >&2
+ ;;
+ zenity)
+ zenity --error --text="$1"
+ ;;
+ kdialog)
+ kdialog --error "$1"
+ ;;
+ esac
+}
+
+dialog_question () {
+ case $DIALOGAPP in
+ terminal)
+ local INPUT
+ read -r -p "$1 [Y/n]: " INPUT
+ echo "${INPUT,,}"
+ ;;
+ zenity)
+ zenity --question --text="$1" || echo "no"
+ ;;
+ kdialog)
+ kdialog --yesno "$1" || echo "no"
+ ;;
+ esac
+}
+
+exec 3>&1 4>&2
+exec 1> "$OUTPUTDIR/$FILEBASE.txt" || {
+ dialog_error "${TERMOUT+\n}Cannot write output file in \"$OUTPUTDIR\",${DIALOGBREAK}trying in \"$OUTPUTDIRFB\" instead.${TERMOUT+\n}"
+ OUTPUTDIR="$OUTPUTDIRFB"
+ exec 1> "$OUTPUTDIR/$FILEBASE.txt" || {
+ dialog_error "${TERMOUT+\n}Cannot write output file in \"$OUTPUTDIR\" either, aborting.${TERMOUT+\n}"
+ exit 1
+ }
+}
+exec 2>&1
+
+printf "\n########## wireless info START ##########\n\n"
+REPORTDATE=$(date +"%d %b %Y %H:%M %Z %z")
+SCRIPTDATE=$(date -u -d "$SCRIPTDATE" +"%d %b %Y %H:%M %Z %z")
+LASTBOOTDT=$(last -FRn 1 reboot | sed -n 's/.*system boot[ ]\+\(.\+\) - .*$/\1/p')
+LASTBOOTDT=$(date -d "$LASTBOOTDT" +"%d %b %Y %H:%M %Z %z")
+printf "Report from: %s\n\n" "$REPORTDATE"
+printf "Booted last: %s\n\n" "$LASTBOOTDT"
+printf "Script from: %s\n" "$SCRIPTDATE"
+
+printf "\n##### release ###########################\n\n"
+lsb_release -idrc
+
+printf "\n##### kernel ############################\n\n"
+uname -srvmpio
+echo
+sed 's/root=[^ ]*//;s/[ ]\+/, /g;s/^BOOT_IMAGE=[^ ]*/Parameters:/' /proc/cmdline
+
+printf "\n##### desktop ###########################\n\n"
+if [ -n "$DESKTOP_SESSION" ]; then
+ DESKTOP="$DESKTOP_SESSION"
+else
+ DESKTOP=$(sed -n 's/^Session=\(.\+\)$/\1/p' "$HOME/.dmrc")
+ DESKDMRC=" (from ~/.dmrc)"
+fi
+if [ -n "$DESKTOP" ]; then
+ if [ -f "/usr/share/xsessions/$DESKTOP.desktop" ]; then
+ DESKTOP=$(sed -n 's/^Name=\(.\+\)$/\1/p' "/usr/share/xsessions/$DESKTOP.desktop")
+ fi
+ echo "${DESKTOP/ Session/}${DESKDMRC}"
+else
+ echo "Could not be determined."
+fi
+
+printf "\n##### lspci #############################\n\n"
+lspci -nnk | grep -iA 2 '^[^[:space:]].*net' | sed '/^--$/d;/^[^[:space:]]/ i\\'
+
+printf "\n##### lsusb #############################\n\n"
+lsusb
+
+printf "\n##### PCMCIA card info ##################\n\n"
+if [ -x /sbin/pccardctl ]; then
+ pccardctl info
+else
+ echo "'pccardctl' is not installed (package \"pcmciautils\")."
+fi
+
+printf "\n##### rfkill ############################\n\n"
+rfkill list all
+
+printf "\n##### lsmod #############################\n\n"
+LSMOD=$(lsmod | egrep "(^|[[:punct:] ])($MODMATCHES|$LSMODMATCHES)[^[:punct:] ]*([[:punct:] ]|$)")
+echo "$LSMOD"
+
+printf "\n##### interfaces ########################\n\n"
+sed '/^#/d;s/^wpa-psk [[:graph:]]\+/wpa-psk <WPA key removed>/' /etc/network/interfaces
+
+printf "\n##### ifconfig ##########################\n\n"
+ifconfig -a | sed '/^lo /,/^$/d'
+
+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##### NetworkManager info ###############\n\n"
+if [ -x /usr/bin/nm-tool ]; then
+ nm-tool
+else
+ nmcli -f all device show | sed '/^GENERAL.DEVICE:[ ]\+lo$/,/^$/d; /^AP\[[0-9]\+\]\./d'
+ echo
+ nmcli -f SSID,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,ACTIVE,IN-USE device wifi list
+fi
+
+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 "\nnm-system-settings.conf (used up to Ubuntu 10.04):\n\n"
+ grep -v '^#' /etc/NetworkManager/nm-system-settings.conf
+fi
+
+printf "\n##### NetworkManager profiles ###########\n\n"
+if [ -n "$SUDO" ]; then
+ trap "" 2 3
+ NMPROFILES=$(find /etc/NetworkManager/system-connections -maxdepth 1 -type f -exec $SUDO${GKSUDO+ -D grep --}${KDESUDO+ -d --comment "<b>grep</b>$KDESUDOCMT" --} grep -vH '^$' {} + 2> /dev/null) && SUDOSUCCESS="yes" || SUDOSUCCESS="no"
+ trap 2 3
+ if [ "$SUDOSUCCESS" = "yes" ]; then
+ ORIGIFS="$IFS"
+ IFS=$'\n'
+ for NMWLPRFFILE in $(sed -n 's/^\(.\+\):type=\(802-11-wireless\|wifi\).*$/\1/p' <<< "$NMPROFILES"); do
+ NMWLPRFFLPERMS=$(stat -c "%a %U" "$NMWLPRFFILE")
+ NMWLPROFILE=($(sed -n "s;^$NMWLPRFFILE:\($NMPROFMATCHES.*\)$;\1 |;p" <<< "$NMPROFILES"))
+ NMWLPROFSOUT+="[[$NMWLPRFFILE]] ($NMWLPRFFLPERMS)"$'\n'"${NMWLPROFILE[@]}"$'\n\n'
+ done
+ IFS="$ORIGIFS"
+ sed 's# | \[#\n\[#g;s#\] |#\]#g;s/ |$//' <<< "$NMWLPROFSOUT" | sed '/^\[[^]]*\]$/d'
+ else
+ echo "Acquisition of admin privileges failed."
+ fi
+else
+ echo "No way to acquire admin privileges found."
+fi
+
+printf "\n##### iw reg get ########################\n\n"
+if [ -x /sbin/iw ]; then
+ if IWREGGET=$(iw reg get 2>&1) && [ -f /etc/timezone ]; then
+ REGION=$(cat /etc/timezone)
+ printf "Region: %s (based on set time zone)\n\n" "$REGION"
+ fi
+ echo "$IWREGGET"
+else
+ echo "'iw' is not installed (package \"iw\")."
+fi
+
+printf "\n##### iwlist channels ###################\n\n"
+iwlist chan
+
+printf "\n##### iwlist scan #######################\n\n"
+if [ -n "$SUDO" ]; then
+ trap "" 2 3
+ IWLISTSCAN=$($SUDO${KDESUDO+ -d} iwlist scan 2>&1) && SUDOSUCCESS="yes" || SUDOSUCCESS="no"
+ trap 2 3
+ if [ "$SUDOSUCCESS" = "yes" ]; then
+ if [[ $IWLISTSCAN = *Frequency:* ]]; then
+ printf "Channel occupancy:\n\n"
+ grep '^[ ]*Frequency:' <<< "$IWLISTSCAN" | sort | uniq -c | sed 's/^[ ]\+\([ ][0-9]\+\)[ ]\+/ \1 APs on /'
+ echo
+ fi
+ egrep -v '^[ ]*IE: Unknown:|ibus-daemon' <<< "$IWLISTSCAN"
+ else
+ echo "Acquisition of admin privileges failed."
+ fi
+else
+ echo "No way to acquire admin privileges found."
+fi
+
+printf "\n##### module infos ######################\n\n"
+MODULES=$(egrep -o "^$MODMATCHES[^ ]*" <<< "$LSMOD")
+for MODULE in $MODULES; do
+ MODINFO=$(modinfo $MODULE | egrep -v "^$MODINFOEXCL:")
+ printf "[%s]\n%s\n\n" "$MODULE" "$MODINFO"
+done
+
+printf "\n##### module parameters #################\n\n"
+for MODULE in $MODULES; do
+ if [ -d /sys/module/$MODULE/parameters ]; then
+ MODPARAMS=$(grep -H '^[[:graph:]]' /sys/module/$MODULE/parameters/* | sed 's#^.*/##;s/:/: /')
+ printf "[%s]\n%s\n\n" "$MODULE" "$MODPARAMS"
+ fi
+done
+
+printf "\n##### /etc/modules ######################\n\n"
+grep -v '^#' /etc/modules
+
+printf "\n##### modprobe options ##################\n\n"
+for MODPROBEFILE in $(find /etc/modprobe.{conf,d} -name "*.conf" -regextype posix-egrep -not -regex ".*$MODPROBEXCL.*" 2> /dev/null | sort); do
+ MODPROBEOPTS=$(egrep -v '^(#|$)' $MODPROBEFILE)
+ if [ -n "$MODPROBEOPTS" ]; then
+ printf "[%s]\n%s\n\n" "$MODPROBEFILE" "$MODPROBEOPTS"
+ fi
+done
+
+printf "\n##### rc.local ##########################\n\n"
+grep -v '^#' /etc/rc.local
+
+printf "\n##### pm-utils ##########################\n\n"
+for PMUTILSFILE in $(find /etc/pm/*.d \( -type f -o -type l \) -regextype posix-egrep -not -regex "$PMUTILSEXCL" | sort); do
+ PMUTFLCONT=$(egrep -v '^(#|$)' $PMUTILSFILE)
+ if [ -n "$PMUTFLCONT" ]; then
+ PMUTFLPERMS=$(stat -c "%a %U" $PMUTILSFILE)
+ printf "[%s] (%s)\n%s\n\n" "$PMUTILSFILE" "$PMUTFLPERMS" "$PMUTFLCONT"
+ fi
+done
+
+printf "\n##### udev rules ########################\n\n"
+for UDEVRLFILE in /etc/udev/rules.d/*net*.rules; do
+ UDEVRULES=$(grep -B1 '^[^#]' $UDEVRLFILE | egrep -v '^(--)?$')
+ if [ -n "$UDEVRULES" ]; then
+ printf "[%s]\n%s\n\n" "$UDEVRLFILE" "$UDEVRULES"
+ fi
+done
+
+printf "\n##### dmesg #############################\n\n"
+dmesg | tail -n 100 | egrep "[[:punct:] ]($MODMATCHES|$DMESGMATCHES)[^[:punct:] ]*[[:punct:] ]" | egrep -v "$DMESGEXCL" | uniq -cf 2 | sed 's/^[ ]\+1[ ]\+//;s/^[ ]\+\([0-9]\+\)[ ]\+\(.\+\)$/\2 (repeated \1 times)/'
+
+printf "\n########## wireless info END ############\n\n"
+
+exec 2>&4 4>&-
+exec 1>&3 3>&-
+
+##### MAC address masking #####
+
+RESULTS=$(cat -s "$OUTPUTDIR/$FILEBASE.txt")$'\n'
+
+ORIGIFS="$IFS"
+IFS=$'\n'
+
+IFACESRAW=$(sed -n '/^##### ifconfig #####/,/^##### /p' <<< "$RESULTS")
+IFACESIDS=($(sed -n "s/^\([^ ]\+\)[ ]\+.*HWaddr.*/'\1' [IF]/p" <<< "$IFACESRAW"))
+IFACESMACS=($(sed -n 's/^[^ ]\+[ ]\+.*HWaddr \([^ ]\+\)[ ]*/\1/p' <<< "$IFACESRAW"))
+
+WLAPSIWLRAW=$(sed -n '/^##### iwlist scan #####/,/^##### /p' <<< "$RESULTS")
+WLAPSIWLIDS=($(sed -n "/^[ ]*Cell [0-9]\+/,/^[ ]*ESSID:/ {/^[ ]*Cell [0-9]\+/h;/^[ ]*ESSID:/ {H;g;s/^[ ]*Cell 0\?\([0-9]\+\).*ESSID:\"\(.*\)\"$/'\2' [AC\1]/p}}" <<< "$WLAPSIWLRAW"))
+WLAPSIWLMACS=($(sed -n 's/^[ ]*Cell [0-9]\+.*Address: \([^ ]\+\)/\1/p' <<< "$WLAPSIWLRAW"))
+
+WLAPSNMRAW=$(sed -n '/^##### NetworkManager info #####/,/^##### / {/^[ ]*Wireless Access Points/,/^$/ {/Wireless Access Points/d;s/^[ ]\+\*\?//;s/:[ ]\+/\t/;p}; /^SSID[ ]\+BSSID[ ]\+/,/^$/ {/^SSID[ ]\{2,\}BSSID[ ]\{2,\}/d;s/[ ]\{2,\}/\t/;p}}' <<< "$RESULTS")
+WLAPSNMIDS=($(awk -F '\t' '{printf "'\''%s'\'' [AN%d]\n", $1, NR}' <<< "$WLAPSNMRAW"))
+WLAPSNMMACS=($(grep -o '\([[:alnum:]]\{2\}:\)\{5\}[[:alnum:]]\{2\}' <<< "$WLAPSNMRAW"))
+
+IFS="$ORIGIFS"
+
+for IFACENR in "${!IFACESMACS[@]}"; do
+ MACMASKSED+="s;${IFACESMACS[$IFACENR]};<MAC ${IFACESIDS[$IFACENR]-address}>;I;"
+done
+
+for WLAPIWLNR in "${!WLAPSIWLMACS[@]}"; do
+ MACMASKSED+="s;${WLAPSIWLMACS[$WLAPIWLNR]};<MAC ${WLAPSIWLIDS[$WLAPIWLNR]-address}>;I;"
+done
+
+for WLAPNMNR in "${!WLAPSNMMACS[@]}"; do
+ MACMASKSED+="s;${WLAPSNMMACS[$WLAPNMNR]};<MAC ${WLAPSNMIDS[$WLAPNMNR]-address}>;I;"
+done
+
+sed "$MACMASKSED/\([[:alnum:]]\{2\}:\)\{6,\}/! s/\([[:alnum:]]\{2\}:\)\{5\}[[:alnum:]]\{2\}/<MAC address>/" <<< "$RESULTS" > "$OUTPUTDIR/$FILEBASE.txt"
+
+##### The End #####
+
+dialog_info "${TERMOUT+\n}Results saved in \"$OUTPUTDIR/$FILEBASE.txt\".${TERMOUT+\n}"
+
+if (( $(stat -c %s "$OUTPUTDIR/$FILEBASE.txt") > 19968 )); then
+ tar -czf "$OUTPUTDIR/$FILEBASE.tar.gz" -C "$OUTPUTDIR" "$FILEBASE.txt" && \
+ dialog_info "Results also archived in \"$OUTPUTDIR/$FILEBASE.tar.gz\",${DIALOGBREAK}as they exceed the 19.5 kB size limit for \".txt\" attachments${DIALOGBREAK}on the Ubuntu Forums.${TERMOUT+\n}" || \
+ dialog_error "Results exceed the 19.5 kB size limit for \".txt\" attachments${DIALOGBREAK}on the Ubuntu Forums, but archive could not be created.${TERMOUT+\n}"
+fi
+
+if [ -x /usr/bin/pastebinit ] && ping -nc 3 -w 6 -i 0.2 paste.ubuntu.com > /dev/null 2>&1; then
+ PASTEBIN=$(dialog_question "Do you also want to post them${DIALOGBREAK}to your default 'pastebinit' provider?")
+ if [[ ! $PASTEBIN =~ ^no?$ ]]; then
+ PASTERESULT=$(pastebinit -i "$OUTPUTDIR/$FILEBASE.txt" -f text 2>&1) && PASTESUCCESS="yes"
+ if [ "$PASTESUCCESS" = "yes" ]; then
+ dialog_info "${TERMOUT+\n}Pastebin successful:\n\n${PASTERESULT}${TERMOUT+\n}"
+ else
+ if [ -n "$PASTERESULT" ]; then
+ dialog_error "${TERMOUT+\n}Pastebin failed, error message is:\n\n${PASTERESULT}${TERMOUT+\n}"
+ else
+ dialog_error "${TERMOUT+\n}Pastebin failed, no error message given.${TERMOUT+\n}"
+ fi
+ fi
+ else
+ echo
+ fi
+fi