diff --git a/meson.build b/meson.build index 2f2f90df2f..ab05c97e34 100644 --- a/meson.build +++ b/meson.build @@ -103,6 +103,7 @@ sysconfdir = join_paths(prefixdir, get_option('sysconfdir')) udevrulesdir = join_paths(prefixdir, get_option('udevrulesdir')) dracutrulesdir = join_paths(prefixdir, get_option('dracutrulesdir')) systemddir = join_paths(prefixdir, get_option('systemddir')) +nmdispatchdir = join_paths(prefixdir, get_option('nmdispatchdir')) rundir = join_paths(prefixdir, get_option('rundir')) std_prefix = prefixdir == '/usr' or prefixdir == '/usr/local' @@ -571,6 +572,21 @@ if want_nvme ) endforeach + nm_dispatcher_files = [ + '80-nvmf-connect-nbft.sh' + ] + + foreach file : nm_dispatcher_files + configure_file( + input: 'nvmf-autoconnect/nm-dispatcher/' + file + '.in', + output: file, + configuration: substs, + install: true, + install_mode: 'rwxr-xr-x', + install_dir: nmdispatchdir + ) + endforeach + install_data( 'completions/bash-nvme-completion.sh', rename: 'nvme', @@ -596,6 +612,7 @@ path_dict = { 'dracutrulesdir': dracutrulesdir, 'rundir': rundir, 'systemddir': systemddir, + 'nmdispatchdir': nmdispatchdir, 'build location': meson.current_build_dir(), } summary(path_dict, section: 'Paths') diff --git a/meson_options.txt b/meson_options.txt index 4d2fe78309..d6f858e566 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -95,6 +95,12 @@ option( value : 'lib/udev/rules.d', description : 'directory for udev rules files' ) +option( + 'nmdispatchdir', + type : 'string', + value : 'lib/NetworkManager/dispatcher.d', + description : 'directory for NetworkManager dispatcher scripts' +) option( 'version-tag', type : 'string', diff --git a/nvmf-autoconnect/nm-dispatcher/80-nvmf-connect-nbft.sh.in b/nvmf-autoconnect/nm-dispatcher/80-nvmf-connect-nbft.sh.in new file mode 100644 index 0000000000..38b9f88c98 --- /dev/null +++ b/nvmf-autoconnect/nm-dispatcher/80-nvmf-connect-nbft.sh.in @@ -0,0 +1,27 @@ +#! /bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later +# +# If an interface is brought up that is configured in the NVMeoF +# Boot Firmware Table (NBFT), try to establish possibly missing +# NVMe connections from the NBFT. +# This can happen if an interface couldn't be brought up during +# initramfs processing, but is activated later on. + +start_nvmf= + +if [ "$2" = up ]; then + case $1 in + nbft*) + start_nvmf=yes + ;; + esac + case $CONNECTION_ID in + "NBFT connection HFI"*) + start_nvmf=yes + ;; + esac +fi + +if [ "$start_nvmf" ]; then + @SYSTEMCTL@ --no-block start nvmf-connect-nbft.service || true +fi