[Unit]
After=dracut-cmdline.service

[Service]
# Override ExecStart=, upstream parses /proc/cmdline, while dracut calls custom
# `getcmdline` function to get cmdline options from /etc/cmdline and
# /etc/cmdline.d/*.conf.
# Also, search `nm-initrd-generator` in /usr/lib, for compatibility with distros
# not using libexec.
ExecStart=
ExecStart=/bin/sh -c ' \
    . /lib/dracut-lib.sh; \
    if [ -x /usr/libexec/nm-initrd-generator ]; then \
        /usr/libexec/nm-initrd-generator -- $(getcmdline); \
    elif [ -x /usr/lib/nm-initrd-generator ]; then \
        /usr/lib/nm-initrd-generator -- $(getcmdline); \
    else \
        warn "nm-initrd-generator not found"; \
    fi \
'
# Complement ExecStartPost= to add an initqueue/finished hook.
ExecStartPost=/bin/sh -c ' \
    . /lib/dracut-lib.sh; \
    if getargbool 0 rd.neednet && [ -e /run/NetworkManager/initrd/neednet ]; then \
        echo "[ -f /tmp/nm.done ]" > "$hookdir"/initqueue/finished/nm.sh; \
    fi \
'
