mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-02 03:37:55 +00:00
More scripts from tools dir.
This commit is contained in:
31
print_udev.sh
Executable file
31
print_udev.sh
Executable file
@@ -0,0 +1,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'"'
|
||||
;;
|
||||
*)
|
||||
#echo "IGNORING: $line"
|
||||
;;
|
||||
esac
|
||||
done <<< "$li_show_lines"
|
||||
Reference in New Issue
Block a user