]>
git.ipfire.org Git - thirdparty/dracut.git/blob - modules.d/40network/net-genrules.sh
3 getargbool
0 rd.neednet
&& NEEDNET
=1
5 # Don't continue if we don't need network
6 if [ -z "$netroot" ] && [ ! -e "/tmp/net.ifaces" ] && [ "$NEEDNET" != "1" ]; then
10 command -v fix_bootif
>/dev
/null || .
/lib
/net-lib.sh
14 # bridge: attempt only the defined interface
15 for i
in /tmp
/bridge.
*.info
; do
16 [ -e "$i" ] ||
continue
20 RAW_IFACES
="$RAW_IFACES $bridgeslaves"
21 MASTER_IFACES
="$MASTER_IFACES $bridgename"
24 # bond: attempt only the defined interface (override bridge defines)
25 for i
in /tmp
/bond.
*.info
; do
26 [ -e "$i" ] ||
continue
30 # It is enough to fire up only one
31 RAW_IFACES
="$RAW_IFACES $bondslaves"
32 MASTER_IFACES
="$MASTER_IFACES ${bondname}"
35 for i
in /tmp
/team.
*.info
; do
36 [ -e "$i" ] ||
continue
40 RAW_IFACES
="$RAW_IFACES ${teamslaves}"
41 MASTER_IFACES
="$MASTER_IFACES ${teammaster}"
44 for i
in /tmp
/vlan.
*.phy
; do
45 [ -e "$i" ] ||
continue
48 RAW_IFACES
="$RAW_IFACES $phydevice"
49 for j
in /tmp
/vlan.
*.
${phydevice}; do
50 [ -e "$j" ] ||
continue
53 MASTER_IFACES
="$MASTER_IFACES ${vlanname}"
57 MASTER_IFACES
="$(trim "$MASTER_IFACES")"
58 RAW_IFACES
="$(trim "$RAW_IFACES")"
60 if [ -z "$IFACES" ]; then
61 [ -e /tmp
/net.ifaces
] && read IFACES
< /tmp
/net.ifaces
64 if [ -e /tmp
/net.bootdev
]; then
65 bootdev
=$
(cat /tmp
/net.bootdev
)
68 ifup
='/sbin/ifup $env{INTERFACE}'
70 runcmd
="RUN+=\"/sbin/initqueue --name ifup-\$env{INTERFACE} --unique --onetime $ifup\""
72 # We have some specific interfaces to handle
73 if [ -n "${RAW_IFACES}${IFACES}" ]; then
74 echo 'SUBSYSTEM!="net", GOTO="net_end"'
75 echo 'ACTION!="add|change|move", GOTO="net_end"'
76 for iface
in $IFACES $RAW_IFACES; do
78 ??
:??
:??
:??
:??
:??
) # MAC address
79 cond
="ATTR{address}==\"$iface\""
80 echo "$cond, $runcmd, GOTO=\"net_end\""
82 ??
-??
-??
-??
-??
-??
) # MAC address in BOOTIF form
83 cond
="ATTR{address}==\"$(fix_bootif $iface)\""
84 echo "$cond, $runcmd, GOTO=\"net_end\""
86 *) # an interface name
87 cond
="ENV{INTERFACE}==\"$iface\""
88 echo "$cond, $runcmd, GOTO=\"net_end\""
89 cond
="NAME==\"$iface\""
90 echo "$cond, $runcmd, GOTO=\"net_end\""
93 # The GOTO prevents us from trying to ifup the same device twice
95 echo 'LABEL="net_end"'
97 for iface
in $IFACES; do
98 if [ "$bootdev" = "$iface" ] ||
[ "$NEEDNET" = "1" ]; then
99 echo "[ -f /tmp/net.${iface}.did-setup ]" >$hookdir/initqueue
/finished
/wait-
$iface.sh
102 # Default: We don't know the interface to use, handle all
103 # Fixme: waiting for the interface as well.
105 cond
='ACTION=="add", SUBSYSTEM=="net", ENV{DEVTYPE}!="wlan|wwan"'
106 # if you change the name of "91-default-net.rules", also change modules.d/80cms/cmssetup.sh
107 echo "$cond, $runcmd" > /etc
/udev
/rules.d
/91-default-net.rules
108 if [ "$NEEDNET" = "1" ]; then
109 echo 'for i in /tmp/net.*.did-setup; do [ -f "$i" ] && exit 0; done; exit 1' >$hookdir/initqueue
/finished
/wait-network.sh
113 # if you change the name of "90-net.rules", also change modules.d/80cms/cmssetup.sh
114 } > /etc
/udev
/rules.d
/90-net.rules