summaryrefslogtreecommitdiffstats
path: root/modules.d/35network-manager/nm-lib.sh
blob: 32a288d528378030bb1447ddbed44fe5f6ebb7d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/sh

type getcmdline > /dev/null 2>&1 || . /lib/dracut-lib.sh

nm_generate_connections() {
    rm -f /run/NetworkManager/system-connections/*
    if [ -x /usr/libexec/nm-initrd-generator ]; then
        # shellcheck disable=SC2046
        /usr/libexec/nm-initrd-generator -- $(getcmdline)
    elif [ -x /usr/lib/nm-initrd-generator ]; then
        # shellcheck disable=SC2046
        /usr/lib/nm-initrd-generator -- $(getcmdline)
    else
        warn "nm-initrd-generator not found"
    fi

    if getargbool 0 rd.neednet; then
        for i in /usr/lib/NetworkManager/system-connections/* \
            /run/NetworkManager/system-connections/* \
            /etc/NetworkManager/system-connections/* \
            /etc/sysconfig/network-scripts/ifcfg-*; do
            [ -f "$i" ] || continue
            mkdir -p "$hookdir"/initqueue/finished
            echo '[ -f /tmp/nm.done ]' > "$hookdir"/initqueue/finished/nm.sh
            mkdir -p /run/NetworkManager/initrd
            : > /run/NetworkManager/initrd/neednet # activate NM services
            break
        done
    fi
}

nm_reload_connections() {
    [ -n "$DRACUT_SYSTEMD" ] && systemctl is-active nm-initrd.service && nmcli connection reload
}