Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/ShExBy/shex_roo.../proc/self/root/usr/lib/kdump
File: kdump-lib.sh
#!/bin/sh
[0] Fix | Delete
#
[1] Fix | Delete
# Kdump common variables and functions
[2] Fix | Delete
#
[3] Fix | Delete
[4] Fix | Delete
DEFAULT_PATH="/var/crash/"
[5] Fix | Delete
FENCE_KDUMP_CONFIG_FILE="/etc/sysconfig/fence_kdump"
[6] Fix | Delete
FENCE_KDUMP_SEND="/usr/libexec/fence_kdump_send"
[7] Fix | Delete
FADUMP_ENABLED_SYS_NODE="/sys/kernel/fadump_enabled"
[8] Fix | Delete
LVM_CONF="/etc/lvm/lvm.conf"
[9] Fix | Delete
[10] Fix | Delete
is_fadump_capable()
[11] Fix | Delete
{
[12] Fix | Delete
# Check if firmware-assisted dump is enabled
[13] Fix | Delete
# if no, fallback to kdump check
[14] Fix | Delete
if [ -f $FADUMP_ENABLED_SYS_NODE ]; then
[15] Fix | Delete
rc=`cat $FADUMP_ENABLED_SYS_NODE`
[16] Fix | Delete
[ $rc -eq 1 ] && return 0
[17] Fix | Delete
fi
[18] Fix | Delete
return 1
[19] Fix | Delete
}
[20] Fix | Delete
[21] Fix | Delete
is_squash_available() {
[22] Fix | Delete
for kmodule in squashfs overlay loop; do
[23] Fix | Delete
if [ -z "$KDUMP_KERNELVER" ]; then
[24] Fix | Delete
modprobe --dry-run $kmodule &>/dev/null || return 1
[25] Fix | Delete
else
[26] Fix | Delete
modprobe -S $KDUMP_KERNELVER --dry-run $kmodule &>/dev/null || return 1
[27] Fix | Delete
fi
[28] Fix | Delete
done
[29] Fix | Delete
}
[30] Fix | Delete
[31] Fix | Delete
perror_exit() {
[32] Fix | Delete
derror "$@"
[33] Fix | Delete
exit 1
[34] Fix | Delete
}
[35] Fix | Delete
[36] Fix | Delete
is_ssh_dump_target()
[37] Fix | Delete
{
[38] Fix | Delete
grep -q "^ssh[[:blank:]].*@" /etc/kdump.conf
[39] Fix | Delete
}
[40] Fix | Delete
[41] Fix | Delete
is_nfs_dump_target()
[42] Fix | Delete
{
[43] Fix | Delete
grep -q "^nfs" /etc/kdump.conf || \
[44] Fix | Delete
[[ $(get_dracut_args_fstype "$(grep "^dracut_args .*\-\-mount" /etc/kdump.conf)") = nfs* ]]
[45] Fix | Delete
}
[46] Fix | Delete
[47] Fix | Delete
is_raw_dump_target()
[48] Fix | Delete
{
[49] Fix | Delete
grep -q "^raw" /etc/kdump.conf
[50] Fix | Delete
}
[51] Fix | Delete
[52] Fix | Delete
is_fs_type_nfs()
[53] Fix | Delete
{
[54] Fix | Delete
local _fstype=$1
[55] Fix | Delete
[ $_fstype = "nfs" ] || [ $_fstype = "nfs4" ] && return 0
[56] Fix | Delete
return 1
[57] Fix | Delete
}
[58] Fix | Delete
[59] Fix | Delete
is_fs_dump_target()
[60] Fix | Delete
{
[61] Fix | Delete
egrep -q "^ext[234]|^xfs|^btrfs|^minix" /etc/kdump.conf
[62] Fix | Delete
}
[63] Fix | Delete
[64] Fix | Delete
is_lvm2_thinp_device()
[65] Fix | Delete
{
[66] Fix | Delete
_device_path=$1
[67] Fix | Delete
_lvm2_thin_device=$(lvm lvs -S 'lv_layout=sparse && lv_layout=thin' \
[68] Fix | Delete
--nosuffix --noheadings -o vg_name,lv_name "$_device_path" 2> /dev/null)
[69] Fix | Delete
[70] Fix | Delete
[ -n "$_lvm2_thin_device" ]
[71] Fix | Delete
}
[72] Fix | Delete
[73] Fix | Delete
strip_comments()
[74] Fix | Delete
{
[75] Fix | Delete
echo $@ | sed -e 's/\(.*\)#.*/\1/'
[76] Fix | Delete
}
[77] Fix | Delete
[78] Fix | Delete
# Read from kdump config file stripping all comments
[79] Fix | Delete
read_strip_comments()
[80] Fix | Delete
{
[81] Fix | Delete
# strip heading spaces, and print any content starting with
[82] Fix | Delete
# neither space or #, and strip everything after #
[83] Fix | Delete
sed -n -e "s/^\s*\([^# \t][^#]\+\).*/\1/gp" $1
[84] Fix | Delete
}
[85] Fix | Delete
[86] Fix | Delete
# Check if fence kdump is configured in Pacemaker cluster
[87] Fix | Delete
is_pcs_fence_kdump()
[88] Fix | Delete
{
[89] Fix | Delete
# no pcs or fence_kdump_send executables installed?
[90] Fix | Delete
type -P pcs > /dev/null || return 1
[91] Fix | Delete
[ -x $FENCE_KDUMP_SEND ] || return 1
[92] Fix | Delete
[93] Fix | Delete
# fence kdump not configured?
[94] Fix | Delete
(pcs cluster cib | grep 'type="fence_kdump"') &> /dev/null || return 1
[95] Fix | Delete
}
[96] Fix | Delete
[97] Fix | Delete
# Check if fence_kdump is configured using kdump options
[98] Fix | Delete
is_generic_fence_kdump()
[99] Fix | Delete
{
[100] Fix | Delete
[ -x $FENCE_KDUMP_SEND ] || return 1
[101] Fix | Delete
[102] Fix | Delete
grep -q "^fence_kdump_nodes" /etc/kdump.conf
[103] Fix | Delete
}
[104] Fix | Delete
[105] Fix | Delete
to_dev_name() {
[106] Fix | Delete
local dev="${1//\"/}"
[107] Fix | Delete
[108] Fix | Delete
case "$dev" in
[109] Fix | Delete
UUID=*)
[110] Fix | Delete
dev=`blkid -U "${dev#UUID=}"`
[111] Fix | Delete
;;
[112] Fix | Delete
LABEL=*)
[113] Fix | Delete
dev=`blkid -L "${dev#LABEL=}"`
[114] Fix | Delete
;;
[115] Fix | Delete
esac
[116] Fix | Delete
echo $dev
[117] Fix | Delete
}
[118] Fix | Delete
[119] Fix | Delete
is_user_configured_dump_target()
[120] Fix | Delete
{
[121] Fix | Delete
return $(is_mount_in_dracut_args || is_ssh_dump_target || is_nfs_dump_target || \
[122] Fix | Delete
is_raw_dump_target || is_fs_dump_target)
[123] Fix | Delete
}
[124] Fix | Delete
[125] Fix | Delete
get_user_configured_dump_disk()
[126] Fix | Delete
{
[127] Fix | Delete
local _target
[128] Fix | Delete
[129] Fix | Delete
_target=$(egrep "^ext[234]|^xfs|^btrfs|^minix|^raw" /etc/kdump.conf 2>/dev/null |awk '{print $2}')
[130] Fix | Delete
[ -n "$_target" ] && echo $_target && return
[131] Fix | Delete
[132] Fix | Delete
_target=$(get_dracut_args_target "$(grep "^dracut_args .*\-\-mount" /etc/kdump.conf)")
[133] Fix | Delete
[ -b "$_target" ] && echo $_target
[134] Fix | Delete
}
[135] Fix | Delete
[136] Fix | Delete
get_root_fs_device()
[137] Fix | Delete
{
[138] Fix | Delete
findmnt -k -f -n -o SOURCE /
[139] Fix | Delete
}
[140] Fix | Delete
[141] Fix | Delete
get_save_path()
[142] Fix | Delete
{
[143] Fix | Delete
local _save_path=$(awk '$1 == "path" {print $2}' /etc/kdump.conf)
[144] Fix | Delete
[ -z "$_save_path" ] && _save_path=$DEFAULT_PATH
[145] Fix | Delete
[146] Fix | Delete
# strip the duplicated "/"
[147] Fix | Delete
echo $_save_path | tr -s /
[148] Fix | Delete
}
[149] Fix | Delete
[150] Fix | Delete
get_block_dump_target()
[151] Fix | Delete
{
[152] Fix | Delete
local _target _path
[153] Fix | Delete
[154] Fix | Delete
if is_ssh_dump_target || is_nfs_dump_target; then
[155] Fix | Delete
return
[156] Fix | Delete
fi
[157] Fix | Delete
[158] Fix | Delete
_target=$(get_user_configured_dump_disk)
[159] Fix | Delete
[ -n "$_target" ] && echo $(to_dev_name $_target) && return
[160] Fix | Delete
[161] Fix | Delete
# Get block device name from local save path
[162] Fix | Delete
_path=$(get_save_path)
[163] Fix | Delete
_target=$(get_target_from_path $_path)
[164] Fix | Delete
[ -b "$_target" ] && echo $(to_dev_name $_target)
[165] Fix | Delete
}
[166] Fix | Delete
[167] Fix | Delete
is_dump_to_rootfs()
[168] Fix | Delete
{
[169] Fix | Delete
grep -E "^(failure_action|default)[[:space:]]dump_to_rootfs" /etc/kdump.conf >/dev/null
[170] Fix | Delete
}
[171] Fix | Delete
[172] Fix | Delete
is_lvm2_thinp_dump_target()
[173] Fix | Delete
{
[174] Fix | Delete
_target=$(get_block_dump_target)
[175] Fix | Delete
[ -n "$_target" ] && is_lvm2_thinp_device "$_target"
[176] Fix | Delete
}
[177] Fix | Delete
[178] Fix | Delete
get_failure_action_target()
[179] Fix | Delete
{
[180] Fix | Delete
local _target
[181] Fix | Delete
[182] Fix | Delete
if is_dump_to_rootfs; then
[183] Fix | Delete
# Get rootfs device name
[184] Fix | Delete
_target=$(get_root_fs_device)
[185] Fix | Delete
[ -b "$_target" ] && echo $(to_dev_name $_target) && return
[186] Fix | Delete
# Then, must be nfs root
[187] Fix | Delete
echo "nfs"
[188] Fix | Delete
fi
[189] Fix | Delete
}
[190] Fix | Delete
[191] Fix | Delete
# Get kdump targets(including root in case of dump_to_rootfs).
[192] Fix | Delete
get_kdump_targets()
[193] Fix | Delete
{
[194] Fix | Delete
local _target _root
[195] Fix | Delete
local kdump_targets
[196] Fix | Delete
[197] Fix | Delete
_target=$(get_block_dump_target)
[198] Fix | Delete
if [ -n "$_target" ]; then
[199] Fix | Delete
kdump_targets=$_target
[200] Fix | Delete
elif is_ssh_dump_target; then
[201] Fix | Delete
kdump_targets="ssh"
[202] Fix | Delete
else
[203] Fix | Delete
kdump_targets="nfs"
[204] Fix | Delete
fi
[205] Fix | Delete
[206] Fix | Delete
# Add the root device if dump_to_rootfs is specified.
[207] Fix | Delete
_root=$(get_failure_action_target)
[208] Fix | Delete
if [ -n "$_root" -a "$kdump_targets" != "$_root" ]; then
[209] Fix | Delete
kdump_targets="$kdump_targets $_root"
[210] Fix | Delete
fi
[211] Fix | Delete
[212] Fix | Delete
echo "$kdump_targets"
[213] Fix | Delete
}
[214] Fix | Delete
[215] Fix | Delete
# Return the bind mount source path, return the path itself if it's not bind mounted
[216] Fix | Delete
# Eg. if /path/to/src is bind mounted to /mnt/bind, then:
[217] Fix | Delete
# /mnt/bind -> /path/to/src, /mnt/bind/dump -> /path/to/src/dump
[218] Fix | Delete
#
[219] Fix | Delete
# findmnt uses the option "-v, --nofsroot" to exclusive the [/dir]
[220] Fix | Delete
# in the SOURCE column for bind-mounts, then if $_mntpoint equals to
[221] Fix | Delete
# $_mntpoint_nofsroot, the mountpoint is not bind mounted directory.
[222] Fix | Delete
#
[223] Fix | Delete
# Below is just an example for mount info
[224] Fix | Delete
# /dev/mapper/atomicos-root[/ostree/deploy/rhel-atomic-host/var], if the
[225] Fix | Delete
# directory is bind mounted. The former part represents the device path, rest
[226] Fix | Delete
# part is the bind mounted directory which quotes by bracket "[]".
[227] Fix | Delete
get_bind_mount_source()
[228] Fix | Delete
{
[229] Fix | Delete
local _path=$1
[230] Fix | Delete
# In case it's a sub path in a mount point, get the mount point first
[231] Fix | Delete
local _mnt_top=$(df $_path | tail -1 | awk '{print $NF}')
[232] Fix | Delete
local _mntpoint=$(findmnt $_mnt_top | tail -n 1 | awk '{print $2}')
[233] Fix | Delete
local _mntpoint_nofsroot=$(findmnt -v $_mnt_top | tail -n 1 | awk '{print $2}')
[234] Fix | Delete
[235] Fix | Delete
if [[ "$_mntpoint" = $_mntpoint_nofsroot ]]; then
[236] Fix | Delete
echo $_path && return
[237] Fix | Delete
fi
[238] Fix | Delete
[239] Fix | Delete
_mntpoint=${_mntpoint#*$_mntpoint_nofsroot}
[240] Fix | Delete
_mntpoint=${_mntpoint#[}
[241] Fix | Delete
_mntpoint=${_mntpoint%]}
[242] Fix | Delete
_path=${_path#$_mnt_top}
[243] Fix | Delete
[244] Fix | Delete
echo $_mntpoint$_path
[245] Fix | Delete
}
[246] Fix | Delete
[247] Fix | Delete
# Return the current underlaying device of a path, ignore bind mounts
[248] Fix | Delete
get_target_from_path()
[249] Fix | Delete
{
[250] Fix | Delete
local _target
[251] Fix | Delete
[252] Fix | Delete
_target=$(df $1 2>/dev/null | tail -1 | awk '{print $1}')
[253] Fix | Delete
[[ "$_target" == "/dev/root" ]] && [[ ! -e /dev/root ]] && _target=$(get_root_fs_device)
[254] Fix | Delete
echo $_target
[255] Fix | Delete
}
[256] Fix | Delete
[257] Fix | Delete
is_mounted()
[258] Fix | Delete
{
[259] Fix | Delete
findmnt -k -n $1 &>/dev/null
[260] Fix | Delete
}
[261] Fix | Delete
[262] Fix | Delete
get_mount_info()
[263] Fix | Delete
{
[264] Fix | Delete
local _info_type=$1 _src_type=$2 _src=$3; shift 3
[265] Fix | Delete
local _info=$(findmnt -k -n -r -o $_info_type --$_src_type $_src $@)
[266] Fix | Delete
[267] Fix | Delete
[ -z "$_info" ] && [ -e "/etc/fstab" ] && _info=$(findmnt -s -n -r -o $_info_type --$_src_type $_src $@)
[268] Fix | Delete
[269] Fix | Delete
echo $_info
[270] Fix | Delete
}
[271] Fix | Delete
[272] Fix | Delete
get_fs_type_from_target()
[273] Fix | Delete
{
[274] Fix | Delete
get_mount_info FSTYPE source $1 -f
[275] Fix | Delete
}
[276] Fix | Delete
[277] Fix | Delete
get_mntopt_from_target()
[278] Fix | Delete
{
[279] Fix | Delete
get_mount_info OPTIONS source $1 -f
[280] Fix | Delete
}
[281] Fix | Delete
# Find the general mount point of a dump target, not the bind mount point
[282] Fix | Delete
get_mntpoint_from_target()
[283] Fix | Delete
{
[284] Fix | Delete
# Expcilitly specify --source to findmnt could ensure non-bind mount is returned
[285] Fix | Delete
get_mount_info TARGET source $1 -f
[286] Fix | Delete
}
[287] Fix | Delete
[288] Fix | Delete
# Get the path where the target will be mounted in kdump kernel
[289] Fix | Delete
# $1: kdump target device
[290] Fix | Delete
get_kdump_mntpoint_from_target()
[291] Fix | Delete
{
[292] Fix | Delete
local _mntpoint=$(get_mntpoint_from_target $1)
[293] Fix | Delete
[294] Fix | Delete
# mount under /sysroot if dump to root disk or mount under
[295] Fix | Delete
# mount under /kdumproot if dump target is not mounted in first kernel
[296] Fix | Delete
# mount under /kdumproot/$_mntpoint in other cases in 2nd kernel.
[297] Fix | Delete
# systemd will be in charge to umount it.
[298] Fix | Delete
if [ -z "$_mntpoint" ];then
[299] Fix | Delete
_mntpoint="/kdumproot"
[300] Fix | Delete
else
[301] Fix | Delete
if [ "$_mntpoint" = "/" ];then
[302] Fix | Delete
_mntpoint="/sysroot"
[303] Fix | Delete
else
[304] Fix | Delete
_mntpoint="/kdumproot/$_mntpoint"
[305] Fix | Delete
fi
[306] Fix | Delete
fi
[307] Fix | Delete
[308] Fix | Delete
# strip duplicated "/"
[309] Fix | Delete
echo $_mntpoint | tr -s "/"
[310] Fix | Delete
}
[311] Fix | Delete
[312] Fix | Delete
# get_option_value <option_name>
[313] Fix | Delete
# retrieves value of option defined in kdump.conf
[314] Fix | Delete
get_option_value() {
[315] Fix | Delete
strip_comments `grep "^$1[[:space:]]\+" /etc/kdump.conf | tail -1 | cut -d\ -f2-`
[316] Fix | Delete
}
[317] Fix | Delete
[318] Fix | Delete
kdump_get_persistent_dev() {
[319] Fix | Delete
local dev="${1//\"/}"
[320] Fix | Delete
[321] Fix | Delete
case "$dev" in
[322] Fix | Delete
UUID=*)
[323] Fix | Delete
dev=`blkid -U "${dev#UUID=}"`
[324] Fix | Delete
;;
[325] Fix | Delete
LABEL=*)
[326] Fix | Delete
dev=`blkid -L "${dev#LABEL=}"`
[327] Fix | Delete
;;
[328] Fix | Delete
esac
[329] Fix | Delete
echo $(get_persistent_dev "$dev")
[330] Fix | Delete
}
[331] Fix | Delete
[332] Fix | Delete
is_ostree()
[333] Fix | Delete
{
[334] Fix | Delete
test -f /run/ostree-booted
[335] Fix | Delete
}
[336] Fix | Delete
[337] Fix | Delete
# fixme, try the best to decide whether the ipv6 addr is allocated by slaac or dhcp6
[338] Fix | Delete
is_ipv6_auto()
[339] Fix | Delete
{
[340] Fix | Delete
local _netdev=$1
[341] Fix | Delete
local _auto=$(cat /proc/sys/net/ipv6/conf/$_netdev/autoconf)
[342] Fix | Delete
if [ $_auto -eq 1 ]; then
[343] Fix | Delete
return 0
[344] Fix | Delete
else
[345] Fix | Delete
return 1
[346] Fix | Delete
fi
[347] Fix | Delete
}
[348] Fix | Delete
[349] Fix | Delete
is_ipv6_address()
[350] Fix | Delete
{
[351] Fix | Delete
echo $1 | grep -q ":"
[352] Fix | Delete
}
[353] Fix | Delete
[354] Fix | Delete
# get ip address or hostname from nfs/ssh config value
[355] Fix | Delete
get_remote_host()
[356] Fix | Delete
{
[357] Fix | Delete
local _config_val=$1
[358] Fix | Delete
[359] Fix | Delete
# ipv6 address in kdump.conf is around with "[]",
[360] Fix | Delete
# factor out the ipv6 address
[361] Fix | Delete
_config_val=${_config_val#*@}
[362] Fix | Delete
_config_val=${_config_val%:/*}
[363] Fix | Delete
_config_val=${_config_val#[}
[364] Fix | Delete
_config_val=${_config_val%]}
[365] Fix | Delete
echo $_config_val
[366] Fix | Delete
}
[367] Fix | Delete
[368] Fix | Delete
is_hostname()
[369] Fix | Delete
{
[370] Fix | Delete
local _hostname=`echo $1 | grep ":"`
[371] Fix | Delete
[372] Fix | Delete
if [ -n "$_hostname" ]; then
[373] Fix | Delete
return 1
[374] Fix | Delete
fi
[375] Fix | Delete
echo $1 | grep -q "[a-zA-Z]"
[376] Fix | Delete
}
[377] Fix | Delete
[378] Fix | Delete
# Copied from "/etc/sysconfig/network-scripts/network-functions"
[379] Fix | Delete
get_hwaddr()
[380] Fix | Delete
{
[381] Fix | Delete
if [ -f "/sys/class/net/${1}/address" ]; then
[382] Fix | Delete
awk '{ print toupper($0) }' < /sys/class/net/${1}/address
[383] Fix | Delete
elif [ -d "/sys/class/net/${1}" ]; then
[384] Fix | Delete
LC_ALL= LANG= ip -o link show ${1} 2>/dev/null | \
[385] Fix | Delete
awk '{ print toupper(gensub(/.*link\/[^ ]* ([[:alnum:]:]*).*/,
[386] Fix | Delete
"\\1", 1)); }'
[387] Fix | Delete
fi
[388] Fix | Delete
}
[389] Fix | Delete
[390] Fix | Delete
get_ifcfg_by_device()
[391] Fix | Delete
{
[392] Fix | Delete
grep -E -i -l "^[[:space:]]*DEVICE=\"*${1}\"*[[:space:]]*$" \
[393] Fix | Delete
/etc/sysconfig/network-scripts/ifcfg-* 2>/dev/null | head -1
[394] Fix | Delete
}
[395] Fix | Delete
[396] Fix | Delete
get_ifcfg_by_hwaddr()
[397] Fix | Delete
{
[398] Fix | Delete
grep -E -i -l "^[[:space:]]*HWADDR=\"*${1}\"*[[:space:]]*$" \
[399] Fix | Delete
/etc/sysconfig/network-scripts/ifcfg-* 2>/dev/null | head -1
[400] Fix | Delete
}
[401] Fix | Delete
[402] Fix | Delete
get_ifcfg_by_uuid()
[403] Fix | Delete
{
[404] Fix | Delete
grep -E -i -l "^[[:space:]]*UUID=\"*${1}\"*[[:space:]]*$" \
[405] Fix | Delete
/etc/sysconfig/network-scripts/ifcfg-* 2>/dev/null | head -1
[406] Fix | Delete
}
[407] Fix | Delete
[408] Fix | Delete
get_ifcfg_by_name()
[409] Fix | Delete
{
[410] Fix | Delete
grep -E -i -l "^[[:space:]]*NAME=\"*${1}\"*[[:space:]]*$" \
[411] Fix | Delete
/etc/sysconfig/network-scripts/ifcfg-* 2>/dev/null | head -1
[412] Fix | Delete
}
[413] Fix | Delete
[414] Fix | Delete
is_nm_running()
[415] Fix | Delete
{
[416] Fix | Delete
[ "$(LANG=C nmcli -t --fields running general status 2>/dev/null)" = "running" ]
[417] Fix | Delete
}
[418] Fix | Delete
[419] Fix | Delete
is_nm_handling()
[420] Fix | Delete
{
[421] Fix | Delete
LANG=C nmcli -t --fields device,state dev status 2>/dev/null \
[422] Fix | Delete
| grep -q "^\(${1}:connected\)\|\(${1}:connecting.*\)$"
[423] Fix | Delete
}
[424] Fix | Delete
[425] Fix | Delete
# $1: netdev name
[426] Fix | Delete
get_ifcfg_nmcli()
[427] Fix | Delete
{
[428] Fix | Delete
local nm_uuid nm_name
[429] Fix | Delete
local ifcfg_file
[430] Fix | Delete
[431] Fix | Delete
# Get the active nmcli config name of $1
[432] Fix | Delete
if is_nm_running && is_nm_handling "${1}" ; then
[433] Fix | Delete
# The configuration "uuid" and "name" generated by nm is wrote to
[434] Fix | Delete
# the ifcfg file as "UUID=<nm_uuid>" and "NAME=<nm_name>".
[435] Fix | Delete
nm_uuid=$(LANG=C nmcli -t --fields uuid,device c show --active 2>/dev/null \
[436] Fix | Delete
| grep "${1}" | head -1 | cut -d':' -f1)
[437] Fix | Delete
nm_name=$(LANG=C nmcli -t --fields name,device c show --active 2>/dev/null \
[438] Fix | Delete
| grep "${1}" | head -1 | cut -d':' -f1)
[439] Fix | Delete
ifcfg_file=$(get_ifcfg_by_uuid "${nm_uuid}")
[440] Fix | Delete
[ -z "${ifcfg_file}" ] && ifcfg_file=$(get_ifcfg_by_name "${nm_name}")
[441] Fix | Delete
fi
[442] Fix | Delete
[443] Fix | Delete
echo -n "${ifcfg_file}"
[444] Fix | Delete
}
[445] Fix | Delete
[446] Fix | Delete
# $1: netdev name
[447] Fix | Delete
get_ifcfg_legacy()
[448] Fix | Delete
{
[449] Fix | Delete
local ifcfg_file
[450] Fix | Delete
[451] Fix | Delete
ifcfg_file="/etc/sysconfig/network-scripts/ifcfg-${1}"
[452] Fix | Delete
[ -f "${ifcfg_file}" ] && echo -n "${ifcfg_file}" && return
[453] Fix | Delete
[454] Fix | Delete
ifcfg_file=$(get_ifcfg_by_name "${1}")
[455] Fix | Delete
[ -f "${ifcfg_file}" ] && echo -n "${ifcfg_file}" && return
[456] Fix | Delete
[457] Fix | Delete
local hwaddr=$(get_hwaddr "${1}")
[458] Fix | Delete
if [ -n "$hwaddr" ]; then
[459] Fix | Delete
ifcfg_file=$(get_ifcfg_by_hwaddr "${hwaddr}")
[460] Fix | Delete
[ -f "${ifcfg_file}" ] && echo -n "${ifcfg_file}" && return
[461] Fix | Delete
fi
[462] Fix | Delete
[463] Fix | Delete
ifcfg_file=$(get_ifcfg_by_device "${1}")
[464] Fix | Delete
[465] Fix | Delete
echo -n "${ifcfg_file}"
[466] Fix | Delete
}
[467] Fix | Delete
[468] Fix | Delete
# $1: netdev name
[469] Fix | Delete
# Return the ifcfg file whole name(including the path) of $1 if any.
[470] Fix | Delete
get_ifcfg_filename() {
[471] Fix | Delete
local ifcfg_file
[472] Fix | Delete
[473] Fix | Delete
ifcfg_file=$(get_ifcfg_nmcli "${1}")
[474] Fix | Delete
if [ -z "${ifcfg_file}" ]; then
[475] Fix | Delete
ifcfg_file=$(get_ifcfg_legacy "${1}")
[476] Fix | Delete
fi
[477] Fix | Delete
[478] Fix | Delete
echo -n "${ifcfg_file}"
[479] Fix | Delete
}
[480] Fix | Delete
[481] Fix | Delete
# returns 0 when omission of a module is desired in dracut_args
[482] Fix | Delete
# returns 1 otherwise
[483] Fix | Delete
is_dracut_mod_omitted() {
[484] Fix | Delete
local dracut_args dracut_mod=$1
[485] Fix | Delete
[486] Fix | Delete
set -- $(grep "^dracut_args" /etc/kdump.conf)
[487] Fix | Delete
while [ $# -gt 0 ]; do
[488] Fix | Delete
case $1 in
[489] Fix | Delete
-o|--omit)
[490] Fix | Delete
[[ " ${2//[^[:alnum:]]/ } " == *" $dracut_mod "* ]] && return 0
[491] Fix | Delete
esac
[492] Fix | Delete
shift
[493] Fix | Delete
done
[494] Fix | Delete
[495] Fix | Delete
return 1
[496] Fix | Delete
}
[497] Fix | Delete
[498] Fix | Delete
is_wdt_active() {
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function