network: split out kernel-network-modules
[dracut.git] / modules.d / 90kernel-network-modules / module-setup.sh
blobb956ebe4bba8c92ae23d5c88bcca239ccb973238
1 #!/bin/bash
3 # called by dracut
4 check() {
5 return 255
8 # called by dracut
9 depends() {
10 return 0
13 # called by dracut
14 installkernel() {
15 # Include wired net drivers, excluding wireless
16 local _arch=$(uname -m)
18 net_module_filter() {
19 local _net_drivers='eth_type_trans|register_virtio_device|usbnet_open'
20 local _unwanted_drivers='/(wireless|isdn|uwb|net/ethernet|net/phy|net/team)/'
21 local _ret
22 # subfunctions inherit following FDs
23 local _merge=8 _side2=9
24 function nmf1() {
25 local _fname _fcont
26 while read _fname; do
27 [[ $_fname =~ $_unwanted_drivers ]] && continue
28 case "$_fname" in
29 *.ko) _fcont="$(< $_fname)" ;;
30 *.ko.gz) _fcont="$(gzip -dc $_fname)" ;;
31 *.ko.xz) _fcont="$(xz -dc $_fname)" ;;
32 esac
33 [[ $_fcont =~ $_net_drivers
34 && ! $_fcont =~ iw_handler_get_spy ]] \
35 && echo "$_fname"
36 done
37 return 0
39 function rotor() {
40 local _f1 _f2
41 while read _f1; do
42 echo "$_f1"
43 if read _f2; then
44 echo "$_f2" 1>&${_side2}
46 done | nmf1 1>&${_merge}
47 return 0
49 # Use two parallel streams to filter alternating modules.
50 set +x
51 eval "( ( rotor ) ${_side2}>&1 | nmf1 ) ${_merge}>&1"
52 [[ $debug ]] && set -x
53 return 0
56 { find_kernel_modules_by_path drivers/net; if [ "$_arch" = "s390" -o "$_arch" = "s390x" ]; then find_kernel_modules_by_path drivers/s390/net; fi; } \
57 | net_module_filter | instmods
59 #instmods() will take care of hostonly
60 instmods \
61 =drivers/net/phy \
62 =drivers/net/team \
63 =drivers/net/ethernet \
64 ecb arc4 bridge stp llc ipv6 bonding 8021q af_packet virtio_net
67 # called by dracut
68 install() {
69 return 0