-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path90_get_network_udev_rule.sh
More file actions
executable file
·45 lines (30 loc) · 985 Bytes
/
90_get_network_udev_rule.sh
File metadata and controls
executable file
·45 lines (30 loc) · 985 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
term_color_red () {
echo -e "\e[91m"
}
term_color_white () {
echo -e "\e[39m"
}
# Check the mac address of the card
ENO=$(ls /sys/class/net | grep en)
WLP=$(ls /sys/class/net | grep wl)
echo $ENO
echo $WLP
echo
term_color_red
echo "Use the command below to set the udev rule for eth0 and wlan0:"
term_color_white
echo
echo "sudo tee /etc/udev/rules.d/70-persistent-net.rules <<EOF"
if [[ $(echo $ENO | wc -m) != 0 ]]; then
ENO_MAC=$(cat /sys/class/net/$ENO/address)
ENO_NAME="eth0"
echo "SUBSYSTEM==\"net\", ACTION==\"add\", DRIVERS==\"?*\", ATTR{address}==\"$ENO_MAC\", ATTR{dev_id}==\"0x0\", ATTR{type}==\"1\", NAME=\"$ENO_NAME\""
fi
if [[ $(echo $WLP | wc -m) != 0 ]]; then
WLP_MAC=$(cat /sys/class/net/$WLP/address)
WLP_NAME="wlan0"
echo "SUBSYSTEM==\"net\", ACTION==\"add\", DRIVERS==\"?*\", ATTR{address}==\"$WLP_MAC\", ATTR{dev_id}==\"0x0\", ATTR{type}==\"1\", KERNEL==\"wlan*\", NAME=\"$WLP_NAME\""
fi
echo "EOF"
echo