123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- #! /bin/bash
- RULES=/etc/udev/rules.d/70-persistent-net.rules
- DEVICES=$(eval echo /sys/class/net/{en*,eth*,ath*,wlan*[0-9],msh*,ra*,sta*,ctc*,lcs*,hsi*})
- function usage
- {
- echo $msg
- echo "init-net-rules.sh is an LFS-specific script to initialize"
- echo "$RULES"
- exit 1
- }
- declare -A VENDORS_IGNORED
- VENDORS_IGNORED['52:54:00:']="kvm"
- VENDORS_IGNORED['00:0c:29:']="vmware"
- VENDORS_IGNORED['00:50:56:']="vmware"
- VENDORS_IGNORED['00:15:5d:']="hyper-v"
- VENDORS_IGNORED['00:00:00:']="invalid"
- declare -A VENDORS
- VENDORS['02:07:01:']="Interlan, DEC, etc"
- VENDORS['02:60:60:']="3com"
- VENDORS['02:60:8c:']="3Com IBM PC; Imagen. etc"
- VENDORS['02:a0:c9:']="intel"
- VENDORS['02:aa:3c:']="Olivetti"
- VENDORS['02:cf:1f:']="Masscomp, Silicon Graphics, etc"
- VENDORS['02:e0:3b:']="Gigabit"
- VENDORS['02:e6:d3:']="BTI"
- VENDORS['52:54:00:']="Realtek"
- VENDORS['52:54:4c:']="Novell"
- VENDORS['52:54:ab:']="Realtek"
- VENDORS['e2:0c:0f:']="Kingston"
- VENDORS['00:16:3e:']="Xensource"
- function ignore_if
- {
- if [[ "${VENDORS_IGNORED[$VENDOR]}" != "" ]]; then return 0; fi
- if [[ "${VENDORS[$VENDOR]}" != "" ]]; then return 1; fi
- byte2=$(echo $VENDOR | cut -c2)
- if echo $byte2 | grep -q "[2367abef]"; then return 0; fi
- return 1
- }
- function comment
- {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- driver=$(basename $(readlink -f $NIC/device/driver/module))
- export COMMENT="net device ${driver}"
- }
- if ! mountpoint -q /sys; then
- msg="/sys mut be mounted"
- usage
- fi
- if ! mountpoint -q /proc; then
- msg="/proc mut be mounted"
- usage
- fi
- if [ -e $RULES ]; then
- msg="The rules file already exists"
- usage
- fi
- if [ -e /proc/xen ]; then
- msg="The rules file should not be created in the Xen environment"
- usage
- fi
- for NIC in $DEVICES; do
- IF=${NIC##*/}
- if echo $NIC | grep -q '*' ; then continue; fi
- export INTERFACE=${NIC##*/}
- export MATCHADDR="$(cat $NIC/address)"
- VENDOR=$(echo $MATCHADDR | cut -c-9)
- if ignore_if; then continue; fi
- export MATCHDEVID="$(cat $NIC/dev_id)"
- export MATCHIFTYPE="$(cat $NIC/type)"
- comment
- /lib/udev/write_net_rules
- done
|