aboutsummaryrefslogtreecommitdiffstats
path: root/wireless-info
diff options
context:
space:
mode:
authorLibravatar Krytarik Raido <krytarik@tuxgarage.com>2015-09-27 15:23:04 +0200
committerLibravatar Krytarik Raido <krytarik@tuxgarage.com>2015-09-27 15:23:04 +0200
commit4faf33e831ac9de1d25fb2736e4d81bf0546b35f (patch)
tree55cd14bdc3340bb7416fb8627acb8d73ab8b392e /wireless-info
parent53511f6b635ccdf0fdcf1f4ec31bf986a749d5bc (diff)
downloadwireless-info-4faf33e831ac9de1d25fb2736e4d81bf0546b35f.tar.bz2
wireless-info-4faf33e831ac9de1d25fb2736e4d81bf0546b35f.tar.xz
wireless-info-4faf33e831ac9de1d25fb2736e4d81bf0546b35f.tar.zst
Account for predictable network interface names.
Diffstat (limited to 'wireless-info')
-rwxr-xr-xwireless-info25
1 files changed, 15 insertions, 10 deletions
diff --git a/wireless-info b/wireless-info
index 84a4b56..c067259 100755
--- a/wireless-info
+++ b/wireless-info
@@ -25,14 +25,15 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-SCRIPTDATE="2015-07-14 19:04 +0200"
+SCRIPTDATE="2015-09-27 02:34 +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)"
+IFACEMATCHES="(wlan[0-9]|eth[0-9])"
+DMESGMATCHES="(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"
@@ -198,7 +199,13 @@ 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'
+IFCONFIG=$(ifconfig -a)
+sed '/^lo /,/^$/d' <<< "$IFCONFIG"
+IFACESETH=($(sed -n 's/^\([^ ]\+\)[ ]\+Link encap:Ethernet.*/\1/p' <<< "$IFCONFIG"))
+if (( ${#IFACESETH[@]} > 0 )); then
+ IFETHMATCHES=${IFACESETH[@]}
+ IFACEMATCHES="($IFACEMATCHES|(${IFETHMATCHES// /|}))"
+fi
printf "\n##### iwconfig ##########################\n\n"
iwconfig
@@ -358,7 +365,7 @@ for UDEVRLFILE in /etc/udev/rules.d/*net*.rules; do
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)/'
+dmesg | tail -n 100 | egrep "[[:punct:] ]($MODMATCHES|$IFACEMATCHES|$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"
@@ -372,14 +379,12 @@ 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"))
+IFACESIDS=($(sed -n "s/^\([^ ]\+\)[ ]\+.*HWaddr.*/'\1' [IF]/p" <<< "$IFCONFIG"))
+IFACESMACS=($(sed -n 's/^[^ ]\+[ ]\+.*HWaddr \([^ ]\+\)[ ]*/\1/p' <<< "$IFCONFIG"))
IFACESIP6S=($(ip6-mac "${IFACESMACS[@]}"))
-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"))
+WLAPSIWLIDS=($(sed -n "/^[ ]*Cell [0-9]\+/,/^[ ]*ESSID:/ {/^[ ]*Cell [0-9]\+/h; /^[ ]*ESSID:/ {H;g;s/^[ ]*Cell 0\?\([0-9]\+\).*ESSID:\"\(.*\)\"$/'\2' [AC\1]/p}}" <<< "$IWLISTSCAN"))
+WLAPSIWLMACS=($(sed -n 's/^[ ]*Cell [0-9]\+.*Address: \([^ ]\+\)/\1/p' <<< "$IWLISTSCAN"))
WLAPSIWLIP6S=($(ip6-mac "${WLAPSIWLMACS[@]}"))
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")