From c69578ca431998d7460d40e58769a05b58bab0e8 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Thu, 1 Apr 2021 15:32:09 +0800 Subject: [PATCH] Add helper to get nmcli connection apath by ifname apath (a D-Bus active connection path) is used for nmcli connection operations, e.g. $ nmcli connection show $apath Signed-off-by: Coiby Xu Acked-by: Kairui Song --- kdump-lib.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/kdump-lib.sh b/kdump-lib.sh index 17414a9..d74ca7d 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -392,6 +392,20 @@ get_nmcli_value_by_field() echo -n "$val" } +# Get nmcli connection apath (a D-Bus active connection path ) by ifname +# +# apath is used for nmcli connection operations, e.g. +# $ nmcli connection show $apath +get_nmcli_connection_apath_by_ifname() +{ + local _ifname=$1 + local _nm_show_cmd="device show $_ifname" + + local _apath=$(get_nmcli_value_by_field "$_nm_show_cmd" "GENERAL.CON-PATH") + + echo -n "$_apath" +} + get_ifcfg_by_device() { grep -E -i -l "^[[:space:]]*DEVICE=\"*${1}\"*[[:space:]]*$" \