From f9d8cabfd1f06fce1e26d6420976609b9a499381 Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Mon, 3 Apr 2023 16:54:59 +0200 Subject: [PATCH] dracut-module-setup: remove dead source_ifcfg_file With the NetworkManager rewrite this function in no longer used. This also allows to remove a lot of dead code in kdump-lib. Signed-off-by: Philipp Rudo Reviewed-by: Coiby Xu --- dracut-module-setup.sh | 13 ------ kdump-lib.sh | 104 ----------------------------------------- 2 files changed, 117 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index e744ba5..ff53d08 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -91,19 +91,6 @@ kdump_is_vlan() { [[ -f /proc/net/vlan/"$1" ]] } -# $1: netdev name -source_ifcfg_file() { - local ifcfg_file - - dwarning "Network Scripts are deprecated. You are encouraged to set up network by NetworkManager." - ifcfg_file=$(get_ifcfg_filename "$1") - if [[ -f ${ifcfg_file} ]]; then - . "${ifcfg_file}" - else - dwarning "The ifcfg file of $1 is not found!" - fi -} - # $1: repeat times # $2: string to be repeated # $3: separator diff --git a/kdump-lib.sh b/kdump-lib.sh index 6b0a83d..bfc650c 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -292,18 +292,6 @@ is_hostname() echo "$1" | grep -q "[a-zA-Z]" } -# Copied from "/etc/sysconfig/network-scripts/network-functions" -get_hwaddr() -{ - if [[ -f "/sys/class/net/$1/address" ]]; then - awk '{ print toupper($0) }' < "/sys/class/net/$1/address" - elif [[ -d "/sys/class/net/$1" ]]; then - LC_ALL="" LANG="" ip -o link show "$1" 2> /dev/null | - awk '{ print toupper(gensub(/.*link\/[^ ]* ([[:alnum:]:]*).*/, - "\\1", 1)); }' - fi -} - # Get value by a field using "nmcli -g" # Usage: get_nmcli_value_by_field # @@ -339,98 +327,6 @@ get_nmcli_connection_apath_by_ifname() get_nmcli_value_by_field "GENERAL.CON-PATH" device show "$_ifname" } -get_ifcfg_by_device() -{ - grep -E -i -l "^[[:space:]]*DEVICE=\"*${1}\"*[[:space:]]*$" \ - /etc/sysconfig/network-scripts/ifcfg-* 2> /dev/null | head -1 -} - -get_ifcfg_by_hwaddr() -{ - grep -E -i -l "^[[:space:]]*HWADDR=\"*${1}\"*[[:space:]]*$" \ - /etc/sysconfig/network-scripts/ifcfg-* 2> /dev/null | head -1 -} - -get_ifcfg_by_uuid() -{ - grep -E -i -l "^[[:space:]]*UUID=\"*${1}\"*[[:space:]]*$" \ - /etc/sysconfig/network-scripts/ifcfg-* 2> /dev/null | head -1 -} - -get_ifcfg_by_name() -{ - grep -E -i -l "^[[:space:]]*NAME=\"*${1}\"*[[:space:]]*$" \ - /etc/sysconfig/network-scripts/ifcfg-* 2> /dev/null | head -1 -} - -is_nm_running() -{ - [[ "$(LANG=C nmcli -t --fields running general status 2> /dev/null)" == "running" ]] -} - -is_nm_handling() -{ - LANG=C nmcli -t --fields device,state dev status 2> /dev/null | - grep -q "^\(${1}:connected\)\|\(${1}:connecting.*\)$" -} - -# $1: netdev name -get_ifcfg_nmcli() -{ - local nm_uuid nm_name - local ifcfg_file - - # Get the active nmcli config name of $1 - if is_nm_running && is_nm_handling "${1}"; then - # The configuration "uuid" and "name" generated by nm is wrote to - # the ifcfg file as "UUID=" and "NAME=". - nm_uuid=$(LANG=C nmcli -t --fields uuid,device c show --active 2> /dev/null | - grep "${1}" | head -1 | cut -d':' -f1) - nm_name=$(LANG=C nmcli -t --fields name,device c show --active 2> /dev/null | - grep "${1}" | head -1 | cut -d':' -f1) - ifcfg_file=$(get_ifcfg_by_uuid "${nm_uuid}") - [[ -z ${ifcfg_file} ]] && ifcfg_file=$(get_ifcfg_by_name "${nm_name}") - fi - - echo -n "${ifcfg_file}" -} - -# $1: netdev name -get_ifcfg_legacy() -{ - local ifcfg_file hwaddr - - ifcfg_file="/etc/sysconfig/network-scripts/ifcfg-${1}" - [[ -f ${ifcfg_file} ]] && echo -n "${ifcfg_file}" && return - - ifcfg_file=$(get_ifcfg_by_name "${1}") - [[ -f ${ifcfg_file} ]] && echo -n "${ifcfg_file}" && return - - hwaddr=$(get_hwaddr "${1}") - if [[ -n $hwaddr ]]; then - ifcfg_file=$(get_ifcfg_by_hwaddr "${hwaddr}") - [[ -f ${ifcfg_file} ]] && echo -n "${ifcfg_file}" && return - fi - - ifcfg_file=$(get_ifcfg_by_device "${1}") - - echo -n "${ifcfg_file}" -} - -# $1: netdev name -# Return the ifcfg file whole name(including the path) of $1 if any. -get_ifcfg_filename() -{ - local ifcfg_file - - ifcfg_file=$(get_ifcfg_nmcli "${1}") - if [[ -z ${ifcfg_file} ]]; then - ifcfg_file=$(get_ifcfg_legacy "${1}") - fi - - echo -n "${ifcfg_file}" -} - # returns 0 when omission of a module is desired in dracut_args # returns 1 otherwise is_dracut_mod_omitted()