debug: add more tools to the dracut debug module
[dracut.git] / modules.d / 40network / module-setup.sh
blobf7e0a8774ca3eafa0cbd369d9a13d8f5c2e3304d
1 #!/bin/bash
3 # called by dracut
4 check() {
5 local _program
7 require_binaries ip arping dhclient || return 1
9 return 255
12 # called by dracut
13 depends() {
14 return 0
17 # called by dracut
18 installkernel() {
19 # Include wired net drivers, excluding wireless
20 local _arch=$(uname -m)
22 net_module_filter() {
23 local _net_drivers='eth_type_trans|register_virtio_device|usbnet_open'
24 local _unwanted_drivers='/(wireless|isdn|uwb|net/ethernet|net/phy|net/team)/'
25 local _ret
26 # subfunctions inherit following FDs
27 local _merge=8 _side2=9
28 function nmf1() {
29 local _fname _fcont
30 while read _fname; do
31 [[ $_fname =~ $_unwanted_drivers ]] && continue
32 case "$_fname" in
33 *.ko) _fcont="$(< $_fname)" ;;
34 *.ko.gz) _fcont="$(gzip -dc $_fname)" ;;
35 *.ko.xz) _fcont="$(xz -dc $_fname)" ;;
36 esac
37 [[ $_fcont =~ $_net_drivers
38 && ! $_fcont =~ iw_handler_get_spy ]] \
39 && echo "$_fname"
40 done
41 return 0
43 function rotor() {
44 local _f1 _f2
45 while read _f1; do
46 echo "$_f1"
47 if read _f2; then
48 echo "$_f2" 1>&${_side2}
50 done | nmf1 1>&${_merge}
51 return 0
53 # Use two parallel streams to filter alternating modules.
54 set +x
55 eval "( ( rotor ) ${_side2}>&1 | nmf1 ) ${_merge}>&1"
56 [[ $debug ]] && set -x
57 return 0
60 { find_kernel_modules_by_path drivers/net; if [ "$_arch" = "s390" -o "$_arch" = "s390x" ]; then find_kernel_modules_by_path drivers/s390/net; fi; } \
61 | net_module_filter | instmods
63 #instmods() will take care of hostonly
64 instmods \
65 =drivers/net/phy \
66 =drivers/net/team \
67 =drivers/net/ethernet \
68 ecb arc4 bridge stp llc ipv6 bonding 8021q af_packet virtio_net
71 # called by dracut
72 install() {
73 local _arch _i _dir
74 inst_multiple ip arping dhclient sed
75 inst_multiple -o ping ping6
76 inst_multiple -o brctl
77 inst_multiple -o teamd teamdctl teamnl
78 inst_simple /etc/libnl/classid
79 inst_script "$moddir/ifup.sh" "/sbin/ifup"
80 inst_script "$moddir/netroot.sh" "/sbin/netroot"
81 inst_script "$moddir/dhclient-script.sh" "/sbin/dhclient-script"
82 inst_simple "$moddir/net-lib.sh" "/lib/net-lib.sh"
83 inst_simple -H "/etc/dhclient.conf"
84 cat "$moddir/dhclient.conf" >> "${initdir}/etc/dhclient.conf"
85 inst_hook pre-udev 50 "$moddir/ifname-genrules.sh"
86 inst_hook pre-udev 60 "$moddir/net-genrules.sh"
87 inst_hook cmdline 91 "$moddir/dhcp-root.sh"
88 inst_hook cmdline 92 "$moddir/parse-ibft.sh"
89 inst_hook cmdline 95 "$moddir/parse-vlan.sh"
90 inst_hook cmdline 96 "$moddir/parse-bond.sh"
91 inst_hook cmdline 96 "$moddir/parse-team.sh"
92 inst_hook cmdline 97 "$moddir/parse-bridge.sh"
93 inst_hook cmdline 98 "$moddir/parse-ip-opts.sh"
94 inst_hook cmdline 99 "$moddir/parse-ifname.sh"
95 inst_hook cleanup 10 "$moddir/kill-dhclient.sh"
97 _arch=$(uname -m)
99 inst_libdir_file {"tls/$_arch/",tls/,"$_arch/",}"libnss_dns.so.*" \
100 {"tls/$_arch/",tls/,"$_arch/",}"libnss_mdns4_minimal.so.*"
102 dracut_need_initqueue