Skip to content

Commit 205a25f

Browse files
macmpipelwell
authored andcommitted
raspinfo: do not assume network interfaces names
1 parent e1e814c commit 205a25f

1 file changed

Lines changed: 26 additions & 19 deletions

File tree

raspinfo/raspinfo

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# IP4 d.d.d.d decimal "s/\([0-9]\{1,3\}\.\)\{3,3\}[0-9]\{1,3\}/x.x.x.x/g"
77
# mac address "s/\([0-9a-fA-F]\{2,2\}\:\)\{5,5\}[0-9a-fA-F]\{2,2\}/m.m.m.m/g"
88

9+
alias filter="sed -e 's/\([0-9a-fA-F]\{1,4\}:\)\{7,7\}[0-9a-fA-F]\{1,4\}/y.y.y.y.y.y.y.y/g' | sed -e 's/[0-9a-fA-F]\{1,4\}:\(:[0-9a-fA-F]\{1,4\}\)\{1,4\}/y::y.y.y.y/g' | sed -e 's/\([0-9]\{1,3\}\.\)\{3,3\}[0-9]\{1,3\}/x.x.x.x/g' | sed -e 's/\([0-9a-fA-F]\{2,2\}\:\)\{5,5\}[0-9a-fA-F]\{2,2\}/m.m.m.m/g'"
910

1011
display_info_drm() {
1112
# kmsprint is more useful, but not always installed
@@ -168,20 +169,6 @@ audio_info() {
168169
}
169170

170171
network_info() {
171-
ifconfig | sed -e "s/\([0-9a-fA-F]\{1,4\}:\)\{7,7\}[0-9a-fA-F]\{1,4\}/y.y.y.y.y.y.y.y/g" | sed -e "s/[0-9a-fA-F]\{1,4\}:\(:[0-9a-fA-F]\{1,4\}\)\{1,4\}/y::y.y.y.y/g" | sed -e "s/\([0-9]\{1,3\}\.\)\{3,3\}[0-9]\{1,3\}/x.x.x.x/g" | sed -e "s/\([0-9a-fA-F]\{2,2\}\:\)\{5,5\}[0-9a-fA-F]\{2,2\}/m.m.m.m/g"
172-
echo
173-
if command -v ethtool > /dev/null; then
174-
ethtool eth0
175-
echo
176-
ethtool --show-eee eth0
177-
echo
178-
ethtool -S eth0
179-
else
180-
echo "ethtool not installed"
181-
fi
182-
}
183-
184-
wifi_info() {
185172
cat /proc/net/wireless 2>/dev/null || echo "/proc/net/wireless not available"
186173
echo
187174
if command -v rfkill >/dev/null; then
@@ -190,8 +177,28 @@ wifi_info() {
190177
echo "rfkill not installed"
191178
fi
192179
echo
180+
193181
if command -v ethtool >/dev/null; then
194-
ethtool -i wlan0
182+
# Using sysfs to identify physical interfaces
183+
for iface in /sys/class/net/*; do
184+
iface_name=$(basename "$iface")
185+
# Check if device directory exists (indicates physical interface)
186+
if [ -d "$iface/device" ]; then
187+
ifconfig $iface_name | filter
188+
if [ -d "$iface/phy80211" ]; then
189+
ethtool -i $iface_name
190+
else
191+
sudo ethtool $iface_name
192+
echo
193+
ethtool --show-eee $iface_name
194+
echo
195+
ethtool -S $iface_name
196+
fi
197+
echo
198+
fi
199+
done
200+
else
201+
echo "ethtool not installed"
195202
fi
196203
}
197204

@@ -246,6 +253,7 @@ vcgencmd mem_reloc_stats
246253
echo
247254
echo "Filesystem information"
248255
echo "----------------------"
256+
echo
249257

250258
df
251259
echo
@@ -254,6 +262,7 @@ cat /proc/swaps
254262
echo
255263
echo "Package version information"
256264
echo "---------------------------"
265+
echo
257266

258267
apt-cache policy raspberrypi-ui-mods | head -2
259268
apt-cache policy raspberrypi-sys-mods | head -2
@@ -269,8 +278,6 @@ echo
269278

270279
network_info
271280
echo
272-
wifi_info
273-
echo
274281

275282
echo "USB Information"
276283
echo "---------------"
@@ -305,6 +312,7 @@ vcgencmd get_config str
305312
echo
306313
echo "cmdline.txt"
307314
echo "-----------"
315+
echo
308316

309317
cat /proc/cmdline
310318

@@ -339,8 +347,7 @@ echo "dmesg log"
339347
echo "---------"
340348
echo
341349

342-
sudo dmesg | sed -e "s/\([0-9a-fA-F]\{1,4\}:\)\{7,7\}[0-9a-fA-F]\{1,4\}/y.y.y.y.y.y.y.y/g" | sed -e "s/[0-9a-fA-F]\{1,4\}:\(:[0-9a-fA-F]\{1,4\}\)\{1,4\}/y::y.y.y.y/g" | sed -e "s/\([0-9a-fA-F]\{2,2\}\:\)\{5,5\}[0-9a-fA-F]\{2,2\}/m.m.m.m/g"
343-
350+
sudo dmesg | filter
344351

345352
if grep -q "^Revision\s*:\s*[ 123][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]1[13457][0-9a-fA-F]$" /proc/cpuinfo
346353
then

0 commit comments

Comments
 (0)