aboutsummaryrefslogtreecommitdiffstats
path: root/wireless-info
diff options
context:
space:
mode:
authorLibravatarKrytarik Raido <krytarik@tuxgarage.com>2018-10-22 05:34:00 +0200
committerLibravatarKrytarik Raido <krytarik@tuxgarage.com>2018-10-22 05:34:00 +0200
commitcc71c068daf4d6cc6e03a2ca340b7966cbdc206e (patch)
tree44fd4c83b72618015e4fe883ba49db62b1745600 /wireless-info
parent341ef8b673455f0f3ea5d2f82c3c2e7c5dbc6f42 (diff)
downloadwireless-info-master.tar.bz2
wireless-info-master.tar.xz
wireless-info-master.tar.zst
Adapt to changes in net-tools.HEADmaster
* Prefer 'ip' over net-tools if available. * Update parsing of net-tools output relevant to further processing.
Diffstat (limited to 'wireless-info')
-rwxr-xr-xwireless-info22
1 files changed, 13 insertions, 9 deletions
diff --git a/wireless-info b/wireless-info
index 74c1bf5..5b345d6 100755
--- a/wireless-info
+++ b/wireless-info
@@ -25,7 +25,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-SCRIPTDATE="2018-10-06 01:16 -0500"
+SCRIPTDATE="2018-10-22 05:34 +0200"
FILEBASE="wireless-info"
OUTPUTDIR="$PWD"
OUTPUTDIRFB="/tmp"
@@ -211,14 +211,16 @@ for IFACESFILE in $(find /etc/network/interfaces{,.d} -type f 2> /dev/null | sor
done
printf "\n##### ifconfig ##########################\n\n"
-if [ -x /sbin/ifconfig ]; then
+if [ -x /bin/ip ]; then
+ IFCONFIG=$(ip address show)
+elif [ -x /sbin/ifconfig ]; then
IFCONFIG=$(ifconfig -a)
else
- IFCONFIG=$(ip address show)
+ echo "'ip' is not installed (package \"iproute2\")."
fi
echo "$IFCONFIG"
IFCONFIG=$(sed -n '1h; 1!H; ${g;s/\n /\\ /g;p}' <<< "$IFCONFIG")
-IFACESETH=($(sed -n 's/^\([^ ]\+\)[ ]\+Link encap:Ethernet.*/\1/p; s#^[0-9]\+: \([^ :]\+\):.* link/ether.*#\1#p' <<< "$IFCONFIG"))
+IFACESETH=($(sed -n 's#^[0-9]\+: \([^ :]\+\):.* link/ether.*#\1#p; s/^\([^ :]\+\):\?.* \(Link encap:Ethernet\|ether\).*/\1/p' <<< "$IFCONFIG"))
if (( ${#IFACESETH[@]} > 0 )); then
IFETHMATCHES=${IFACESETH[@]}
IFACEMATCHES="($IFACEMATCHES|(${IFETHMATCHES// /|}))"
@@ -228,10 +230,12 @@ printf "\n##### iwconfig ##########################\n\n"
iwconfig
printf "\n##### route #############################\n\n"
-if [ -x /sbin/route ]; then
+if [ -x /bin/ip ]; then
+ ip route show
+elif [ -x /sbin/route ]; then
route -n
else
- ip route show
+ echo "'ip' is not installed (package \"iproute2\")."
fi
printf "\n##### resolv.conf #######################\n\n"
@@ -410,8 +414,8 @@ RESULTS=$(cat -s "$OUTPUTDIR/$FILEBASE.txt")$'\n'
ORIGIFS="$IFS"
IFS=$'\n'
-IFACESIDS=($(sed -n "/\([[:alnum:]]\{2\}:\)\{5\}[[:alnum:]]\{2\}/ {/\(00:\)\{5\}00/! {s/^\([^ ]\+\)[ ]\+.*HWaddr.*/'\1'/p; s/^[0-9]\+: \([^ :]\+\):.*/'\1'/p}}" <<< "$IFCONFIG"))
-IFACESMACS=($(sed -n '/\(00:\)\{5\}00/! s#.*\(HWaddr\|link/[^ ]\+\) \(\([[:alnum:]]\{2\}:\)\{5\}[[:alnum:]]\{2\}\).*#\2#p' <<< "$IFCONFIG"))
+IFACESIDS=($(sed -n "/\([[:alnum:]]\{2\}:\)\{5\}[[:alnum:]]\{2\}/ {/\(00:\)\{5\}00/! {s/^[0-9]\+: \([^ :]\+\):.*/'\1'/p; s/^\([^ :]\+\):\? .*/'\1'/p}}" <<< "$IFCONFIG"))
+IFACESMACS=($(sed -n '/\(00:\)\{5\}00/! s#.*\(HWaddr\|link/[^ ]\+\|ether\) \(\([[:alnum:]]\{2\}:\)\{5\}[[:alnum:]]\{2\}\).*#\2#p' <<< "$IFCONFIG"))
IFACESIP6S=($(ip6-mac "${IFACESMACS[@]}"))
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"))
@@ -444,7 +448,7 @@ for WLAPNMNR in "${!WLAPSNMMACS[@]}"; do
MACMASKSED+=" /${WLAPSNMIP6S[$WLAPNMNR]}/ s;${WLAPSNMIP6S[$WLAPNMNR]/#\\(::/\(};<IP6 ${WLAPSNMIDS[$WLAPNMNR]} [AN$(($WLAPNMNR + 1))]>;I;"
done
-sed "$MACMASKSED /\([[:alnum:]]\{2\}:\)\{6,\}/! s/\([[:alnum:]]\{2\}:\)\{5\}[[:alnum:]]\{2\}/<MAC address>/" <<< "$RESULTS" > "$OUTPUTDIR/$FILEBASE.txt"
+sed "$MACMASKSED /\([[:alnum:]]\{2\}:\)\{6,\}/! s/\([[:alnum:]]\{2\}:\)\{5\}[[:alnum:]]\{2\}/<MAC address>/g" <<< "$RESULTS" > "$OUTPUTDIR/$FILEBASE.txt"
##### The End #####