]> git.ipfire.org Git - thirdparty/dracut.git/blob - modules.d/35network-manager/module-setup.sh
modules/network-manager: Install `ip`
[thirdparty/dracut.git] / modules.d / 35network-manager / module-setup.sh
1 #!/bin/bash
2
3 # called by dracut
4 check() {
5 local _program
6
7 require_binaries sed grep || return 1
8
9 # do not add this module by default
10 return 255
11 }
12
13 # called by dracut
14 depends() {
15 return 0
16 }
17
18 # called by dracut
19 installkernel() {
20 return 0
21 }
22
23 # called by dracut
24 install() {
25 local _nm_version
26
27 _nm_version=$(NetworkManager --version)
28
29 # We don't need `ip` but having it is *really* useful for people debugging
30 # in an emergency shell.
31 inst_multiple ip sed grep
32
33 inst NetworkManager
34 inst /usr/libexec/nm-initrd-generator
35 inst_multiple -o teamd dhclient
36 inst_hook cmdline 99 "$moddir/nm-config.sh"
37 inst_hook initqueue/settled 99 "$moddir/nm-run.sh"
38 inst_rules 85-nm-unmanaged.rules
39 inst_libdir_file "NetworkManager/$_nm_version/libnm-device-plugin-team.so"
40
41 if [[ -x "$initdir/usr/sbin/dhclient" ]]; then
42 inst /usr/libexec/nm-dhcp-helper
43 elif ! [[ -e "$initdir/etc/machine-id" ]]; then
44 # The internal DHCP client silently fails if we
45 # have no machine-id
46 systemd-machine-id-setup --root="$initdir"
47 fi
48
49 # We don't install the ifcfg files from the host automatically.
50 # But if the user chooses to include them, we pull in the machinery to read them.
51 if ! [[ -d "$initdir/etc/sysconfig/network-scripts" ]]; then
52 inst_libdir_file "NetworkManager/$_nm_version/libnm-settings-plugin-ifcfg-rh.so"
53 fi
54 }