-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathprint_udev.sh
More file actions
executable file
·31 lines (29 loc) · 878 Bytes
/
print_udev.sh
File metadata and controls
executable file
·31 lines (29 loc) · 878 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
li_show_lines=$(ip -o li show)
while read line ; do
#echo "* $line"
line=${line#*: }
ifname=''
mac=''
case $line in
eth* | enp* | wlan*)
#echo "LIKE: $line"
hunks=($line);
ifname="${hunks[0]}"
ifname="${ifname%:*}"
#echo "N: ${#hunks[@]}"
for i in `seq 1 ${#hunks[@]}`; do
#echo "$i ${hunks[$i]}"
if [ ! -z "${hunks[$i]}" -a "${hunks[$i]}" = "link/ether" ]; then
mac="${hunks[ $[ $i + 1] ]}"
break;
fi
done
#echo "Hi! $ifname has [$mac]"
echo 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="'$mac'", ATTR{dev_id}=="0x0", ATTR{type}=="1", NAME="'$ifname'" ENV{NM_UNMANAGED}="1"'
;;
*)
#echo "IGNORING: $line"
;;
esac
done <<< "$li_show_lines"