source: udev-lfs/init-net-rules.sh@ cdd87ad

10.0 10.0-rc1 10.1 10.1-rc1 11.0 11.0-rc1 11.0-rc2 11.0-rc3 11.1 11.1-rc1 11.2 11.2-rc1 11.3 11.3-rc1 12.0 12.0-rc1 12.1 12.1-rc1 7.3 7.4 7.5 7.5-systemd 7.6 7.6-systemd 7.7 7.7-systemd 7.8 7.8-systemd 7.9 7.9-systemd 8.0 8.1 8.2 8.3 8.4 9.0 9.1 arm bdubbs/gcc13 ml-11.0 multilib renodr/libudev-from-systemd s6-init trunk xry111/arm64 xry111/arm64-12.0 xry111/clfs-ng xry111/lfs-next xry111/loongarch xry111/loongarch-12.0 xry111/loongarch-12.1 xry111/mips64el xry111/pip3 xry111/rust-wip-20221008 xry111/update-glibc
Last change on this file since cdd87ad was cdd87ad, checked in by Bruce Dubbs <bdubbs@…>, 11 years ago

Revised explanation for /etc/modprobe.conf.

Update udev-lfs init-net-rules.sh script for "en*" devices
introduced in systemd-197

git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@10094 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

  • Property mode set to 100644
File size: 3.6 KB
Line 
1#! /bin/bash
2
3# This script generates rules for persistent network device naming
4# Data from udev-182 75-persistent-net-generator.rules
5# Updated fof udev-197 (DEVICES=en*)
6
7RULES=/etc/udev/rules.d/70-persistent-net.rules
8DEVICES=$(eval echo /sys/class/net/{en*,eth*,ath*,wlan*[0-9],msh*,ra*,sta*,ctc*,lcs*,hsi*})
9
10function usage
11{
12 echo $msg
13 echo "init-net-rules.sh is an LFS-specific script to initialize"
14 echo "$RULES"
15 exit 1
16}
17
18declare -A VENDORS_IGNORED
19VENDORS_IGNORED['52:54:00:']="kvm"
20VENDORS_IGNORED['00:0c:29:']="vmware"
21VENDORS_IGNORED['00:50:56:']="vmware"
22VENDORS_IGNORED['00:15:5d:']="hyper-v"
23VENDORS_IGNORED['00:00:00:']="invalid"
24
25declare -A VENDORS
26VENDORS['02:07:01:']="Interlan, DEC, etc"
27VENDORS['02:60:60:']="3com"
28VENDORS['02:60:8c:']="3Com IBM PC; Imagen. etc"
29VENDORS['02:a0:c9:']="intel"
30VENDORS['02:aa:3c:']="Olivetti"
31VENDORS['02:cf:1f:']="Masscomp, Silicon Graphics, etc"
32VENDORS['02:e0:3b:']="Gigabit"
33VENDORS['02:e6:d3:']="BTI"
34VENDORS['52:54:00:']="Realtek"
35VENDORS['52:54:4c:']="Novell"
36VENDORS['52:54:ab:']="Realtek"
37VENDORS['e2:0c:0f:']="Kingston"
38VENDORS['00:16:3e:']="Xensource"
39
40function ignore_if
41{
42 if [[ "${VENDORS_IGNORED[$VENDOR]}" != "" ]]; then return 0; fi
43 if [[ "${VENDORS[$VENDOR]}" != "" ]]; then return 1; fi
44
45 byte2=$(echo $VENDOR | cut -c2)
46 if echo $byte2 | grep -q "[2367abef]"; then return 0; fi
47
48 return 1 # Default is to not ignore
49}
50
51function comment
52{
53 # Not implemented
54 # SUBSYSTEMS=="pci"
55 # export COMMENT="PCI device $attr{vendor}:$attr{device} ($driver)"
56
57 # SUBSYSTEMS=="usb", ATTRS{idVendor}=="?*"
58 # export COMMENT="USB device 0x$attr{idVendor}:0x$attr{idProduct} ($driver)"
59
60 # SUBSYSTEMS=="pcmcia",
61 # export COMMENT="PCMCIA device $attr{card_id}:$attr{manf_id} ($driver)"
62
63 # SUBSYSTEMS=="ieee1394",
64 # export COMMENT="Firewire device $attr{host_id})"
65
66 # ibmveth likes to use "locally administered" MAC addresses
67 # DRIVERS=="ibmveth",
68 # export COMMENT="ibmveth ($id)"
69
70 # S/390 uses id matches only, do not use MAC address match
71 # SUBSYSTEMS=="ccwgroup",
72 # export COMMENT="S/390 $driver device at $id",
73 # export MATCHID="$id"
74 # export MATCHDRV="$driver"
75 # export MATCHADDR=""
76
77 # Default
78 driver=$(basename $(readlink -f $NIC/device/driver/module))
79 export COMMENT="net device ${driver}"
80}
81
82if ! mountpoint -q /sys; then
83 msg="/sys mut be mounted"
84 usage
85fi
86
87if ! mountpoint -q /proc; then
88 msg="/proc mut be mounted"
89 usage
90fi
91
92if [ -e $RULES ]; then
93 msg="The rules file already exists"
94 usage
95fi
96
97# Ignore Xen virtual interfaces
98if [ -e /proc/xen ]; then
99 msg="The rules file should not be created in the Xen environment"
100 usage
101fi
102
103# Variables used to communicate with write_net_rules:
104# INTERFACE simple interface name
105# MATCHADDR MAC address used for the match
106# MATCHID bus_id used for the match
107# MATCHDRV driver name used for the match
108# MATCHIFTYPE interface type match
109# COMMENT comment to add to the generated rule
110# INTERFACE_NAME requested name supplied by external tool
111# INTERFACE_NEW new interface name returned by rule writer
112
113for NIC in $DEVICES; do
114 IF=${NIC##*/}
115 if echo $NIC | grep -q '*' ; then continue; fi
116
117 export INTERFACE=${NIC##*/} # Simple interface name
118 export MATCHADDR="$(cat $NIC/address)" # Read MAC address
119
120 VENDOR=$(echo $MATCHADDR | cut -c-9)
121 if ignore_if; then continue; fi
122
123 export MATCHDEVID="$(cat $NIC/dev_id)"
124 export MATCHIFTYPE="$(cat $NIC/type)" # Read interface type
125 comment
126
127 /lib/udev/write_net_rules
128done
129
Note: See TracBrowser for help on using the repository browser.