bash scripts: reformat with shfmt

This is a batch update done with:
shfmt -s -w mkfadumprd mkdumprd kdumpctl *-module-setup.sh

Clean up code style and reduce code base size, no behaviour change.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Philipp Rudo <prudo@redhat.com>
This commit is contained in:
Kairui Song 2021-09-14 02:25:40 +08:00
parent 4f75e16700
commit 0e4b66b1ab
5 changed files with 570 additions and 559 deletions

View File

@ -7,8 +7,7 @@ KDUMP_INITRD=""
check() { check() {
if [[ ! -f /etc/sysconfig/kdump ]] || [[ ! -f /lib/kdump/kdump-lib.sh ]] \ if [[ ! -f /etc/sysconfig/kdump ]] || [[ ! -f /lib/kdump/kdump-lib.sh ]] \
|| [[ -n "${IN_KDUMP}" ]] || [[ -n ${IN_KDUMP} ]]; then
then
return 1 return 1
fi fi
return 255 return 255
@ -25,7 +24,7 @@ prepare_kernel_initrd() {
prepare_kdump_bootinfo prepare_kdump_bootinfo
# $kernel is a variable from dracut # $kernel is a variable from dracut
if [[ "$KDUMP_KERNELVER" != "$kernel" ]]; then if [[ $KDUMP_KERNELVER != "$kernel" ]]; then
dwarn "Using kernel version '$KDUMP_KERNELVER' for early kdump," \ dwarn "Using kernel version '$KDUMP_KERNELVER' for early kdump," \
"but the initramfs is generated for kernel version '$kernel'" "but the initramfs is generated for kernel version '$kernel'"
fi fi
@ -33,12 +32,12 @@ prepare_kernel_initrd() {
install() { install() {
prepare_kernel_initrd prepare_kernel_initrd
if [[ ! -f "$KDUMP_KERNEL" ]]; then if [[ ! -f $KDUMP_KERNEL ]]; then
derror "Could not find required kernel for earlykdump," \ derror "Could not find required kernel for earlykdump," \
"earlykdump will not work!" "earlykdump will not work!"
return 1 return 1
fi fi
if [[ ! -f "$KDUMP_INITRD" ]]; then if [[ ! -f $KDUMP_INITRD ]]; then
derror "Could not find required kdump initramfs for earlykdump," \ derror "Could not find required kdump initramfs for earlykdump," \
"please ensure kdump initramfs is generated first," \ "please ensure kdump initramfs is generated first," \
"earlykdump will not work!" "earlykdump will not work!"

View File

@ -11,8 +11,7 @@ kdump_module_init() {
check() { check() {
[[ $debug ]] && set -x [[ $debug ]] && set -x
#kdumpctl sets this explicitly #kdumpctl sets this explicitly
if [[ -z "$IN_KDUMP" ]] || [[ ! -f /etc/kdump.conf ]] if [[ -z $IN_KDUMP ]] || [[ ! -f /etc/kdump.conf ]]; then
then
return 1 return 1
fi fi
return 0 return 0
@ -41,7 +40,7 @@ depends() {
_dep="$_dep ssh-client" _dep="$_dep ssh-client"
fi fi
if [[ "$(uname -m)" = "s390x" ]]; then if [[ "$(uname -m)" == "s390x" ]]; then
_dep="$_dep znet" _dep="$_dep znet"
fi fi
@ -78,7 +77,7 @@ source_ifcfg_file() {
dwarning "Network Scripts are deprecated. You are encouraged to set up network by NetworkManager." dwarning "Network Scripts are deprecated. You are encouraged to set up network by NetworkManager."
ifcfg_file=$(get_ifcfg_filename "$1") ifcfg_file=$(get_ifcfg_filename "$1")
if [[ -f "${ifcfg_file}" ]]; then if [[ -f ${ifcfg_file} ]]; then
. "${ifcfg_file}" . "${ifcfg_file}"
else else
dwarning "The ifcfg file of $1 is not found!" dwarning "The ifcfg file of $1 is not found!"
@ -96,24 +95,22 @@ kdump_setup_dns() {
# shellcheck disable=SC2206 # shellcheck disable=SC2206
array=(${_tmp//|/ }) array=(${_tmp//|/ })
if [[ ${array[*]} ]]; then if [[ ${array[*]} ]]; then
for _dns in "${array[@]}" for _dns in "${array[@]}"; do
do
echo "nameserver=$_dns" >> "$_dnsfile" echo "nameserver=$_dns" >> "$_dnsfile"
done done
else else
dwarning "Failed to get DNS info via nmcli output. Now try sourcing ifcfg script" dwarning "Failed to get DNS info via nmcli output. Now try sourcing ifcfg script"
source_ifcfg_file "$_netdev" source_ifcfg_file "$_netdev"
[[ -n "$DNS1" ]] && echo "nameserver=$DNS1" > "$_dnsfile" [[ -n $DNS1 ]] && echo "nameserver=$DNS1" > "$_dnsfile"
[[ -n "$DNS2" ]] && echo "nameserver=$DNS2" >> "$_dnsfile" [[ -n $DNS2 ]] && echo "nameserver=$DNS2" >> "$_dnsfile"
fi fi
while read -r content; while read -r content; do
do
_nameserver=$(echo "$content" | grep ^nameserver) _nameserver=$(echo "$content" | grep ^nameserver)
[[ -z "$_nameserver" ]] && continue [[ -z $_nameserver ]] && continue
_dns=$(echo "$_nameserver" | awk '{print $2}') _dns=$(echo "$_nameserver" | awk '{print $2}')
[[ -z "$_dns" ]] && continue [[ -z $_dns ]] && continue
if [[ ! -f $_dnsfile ]] || ! grep -q "$_dns" "$_dnsfile"; then if [[ ! -f $_dnsfile ]] || ! grep -q "$_dns" "$_dnsfile"; then
echo "nameserver=$_dns" >> "$_dnsfile" echo "nameserver=$_dns" >> "$_dnsfile"
@ -130,7 +127,7 @@ repeatedly_join_str() {
local _separator="$3" local _separator="$3"
local i _res local i _res
if [[ "$_count" -le 0 ]]; then if [[ $_count -le 0 ]]; then
echo -n "" echo -n ""
return return
fi fi
@ -139,7 +136,7 @@ repeatedly_join_str() {
_res="$_str" _res="$_str"
((_count--)) ((_count--))
while [[ "$i" -lt "$_count" ]]; do while [[ $i -lt $_count ]]; do
((i++)) ((i++))
_res="${_res}${_separator}${_str}" _res="${_res}${_separator}${_str}"
done done
@ -160,14 +157,14 @@ cal_netmask_by_prefix() {
local _count _res _octets_per_group _octets_total _seperator _total_groups local _count _res _octets_per_group _octets_total _seperator _total_groups
local _max_group_value _max_group_value_repr _bits_per_group _tmp _zero_bits local _max_group_value _max_group_value_repr _bits_per_group _tmp _zero_bits
if [[ "$_ipv6_flag" == "-6" ]]; then if [[ $_ipv6_flag == "-6" ]]; then
_ipv6=1 _ipv6=1
else else
_ipv6=0 _ipv6=0
fi fi
if [[ "$_prefix" -lt 0 || "$_prefix" -gt 128 ]] || \ if [[ $_prefix -lt 0 || $_prefix -gt 128 ]] \
( ((!_ipv6)) && [[ "$_prefix" -gt 32 ]] ); then || ( ((!_ipv6)) && [[ $_prefix -gt 32 ]]); then
derror "Bad prefix:$_prefix for calculating netmask" derror "Bad prefix:$_prefix for calculating netmask"
exit 1 exit 1
fi fi
@ -198,13 +195,13 @@ cal_netmask_by_prefix() {
_tmp=$((_octets_total * _bits_per_octet - _prefix)) _tmp=$((_octets_total * _bits_per_octet - _prefix))
_zero_bits=$((_tmp % _bits_per_group)) _zero_bits=$((_tmp % _bits_per_group))
if [[ "$_zero_bits" -ne 0 ]]; then if [[ $_zero_bits -ne 0 ]]; then
_second_part=$((_max_group_value >> _zero_bits << _zero_bits)) _second_part=$((_max_group_value >> _zero_bits << _zero_bits))
if ((_ipv6)); then if ((_ipv6)); then
_second_part=$(printf "%x" $_second_part) _second_part=$(printf "%x" $_second_part)
fi fi
((_count++)) ((_count++))
if [[ -z "$_first_part" ]]; then if [[ -z $_first_part ]]; then
_res="$_second_part" _res="$_second_part"
else else
_res="${_first_part}${_seperator}${_second_part}" _res="${_first_part}${_seperator}${_second_part}"
@ -212,19 +209,19 @@ cal_netmask_by_prefix() {
fi fi
_count=$((_total_groups - _count)) _count=$((_total_groups - _count))
if [[ "$_count" -eq 0 ]]; then if [[ $_count -eq 0 ]]; then
echo -n "$_res" echo -n "$_res"
return return
fi fi
if ((_ipv6)) && [[ "$_count" -gt 1 ]] ; then if ((_ipv6)) && [[ $_count -gt 1 ]]; then
# use condensed notion for IPv6 # use condensed notion for IPv6
_third_part=":" _third_part=":"
else else
_third_part=$(repeatedly_join_str "$_count" "0" "$_seperator") _third_part=$(repeatedly_join_str "$_count" "0" "$_seperator")
fi fi
if [[ -z "$_res" ]] && ((!_ipv6)) ; then if [[ -z $_res ]] && ((!_ipv6)); then
echo -n "${_third_part}" echo -n "${_third_part}"
else else
echo -n "${_res}${_seperator}${_third_part}" echo -n "${_res}${_seperator}${_third_part}"
@ -244,9 +241,9 @@ kdump_static_ip() {
_ipv6_flag="-6" _ipv6_flag="-6"
fi fi
if [[ -n "$_ipaddr" ]]; then if [[ -n $_ipaddr ]]; then
_gateway=$(ip $_ipv6_flag route list dev "$_netdev" | \ _gateway=$(ip $_ipv6_flag route list dev "$_netdev" \
awk '/^default /{print $3}' | head -n 1) | awk '/^default /{print $3}' | head -n 1)
if [[ "x" != "x"$_ipv6_flag ]]; then if [[ "x" != "x"$_ipv6_flag ]]; then
# _ipaddr="2002::56ff:feb6:56d5/64", _netmask is the number after "/" # _ipaddr="2002::56ff:feb6:56d5/64", _netmask is the number after "/"
@ -263,9 +260,9 @@ kdump_static_ip() {
echo -n "${_srcaddr}::${_gateway}:${_netmask}::" echo -n "${_srcaddr}::${_gateway}:${_netmask}::"
fi fi
/sbin/ip $_ipv6_flag route show | grep -v default |\ /sbin/ip $_ipv6_flag route show | grep -v default \
grep ".*via.* $_netdev " | grep -v "^[[:space:]]*nexthop" |\ | grep ".*via.* $_netdev " | grep -v "^[[:space:]]*nexthop" \
while read -r _route; do | while read -r _route; do
_target=$(echo "$_route" | awk '{print $1}') _target=$(echo "$_route" | awk '{print $1}')
_nexthop=$(echo "$_route" | awk '{print $3}') _nexthop=$(echo "$_route" | awk '{print $3}')
if [[ "x" != "x"$_ipv6_flag ]]; then if [[ "x" != "x"$_ipv6_flag ]]; then
@ -287,14 +284,14 @@ kdump_handle_mulitpath_route() {
fi fi
while IFS="" read -r _route; do while IFS="" read -r _route; do
if [[ "$_route" =~ [[:space:]]+nexthop ]]; then if [[ $_route =~ [[:space:]]+nexthop ]]; then
_route=${_route##[[:space:]]} _route=${_route##[[:space:]]}
# Parse multipath route, using previous _target # Parse multipath route, using previous _target
[[ "$_target" == 'default' ]] && continue [[ $_target == 'default' ]] && continue
[[ "$_route" =~ .*via.*\ $_netdev ]] || continue [[ $_route =~ .*via.*\ $_netdev ]] || continue
_weight=$(echo "$_route" | cut -d ' ' -f7) _weight=$(echo "$_route" | cut -d ' ' -f7)
if [[ "$_weight" -gt "$_max_weight" ]]; then if [[ $_weight -gt $_max_weight ]]; then
_nexthop=$(echo "$_route" | cut -d ' ' -f3) _nexthop=$(echo "$_route" | cut -d ' ' -f3)
_max_weight=$_weight _max_weight=$_weight
if [[ "x" != "x"$_ipv6_flag ]]; then if [[ "x" != "x"$_ipv6_flag ]]; then
@ -304,7 +301,7 @@ kdump_handle_mulitpath_route() {
fi fi
fi fi
else else
[[ -n "$_rule" ]] && echo "$_rule" [[ -n $_rule ]] && echo "$_rule"
_target=$(echo "$_route" | cut -d ' ' -f1) _target=$(echo "$_route" | cut -d ' ' -f1)
_rule="" _max_weight=0 _weight=0 _rule="" _max_weight=0 _weight=0
fi fi
@ -323,8 +320,7 @@ kdump_get_mac_addr() {
kdump_get_perm_addr() { kdump_get_perm_addr() {
local addr local addr
addr=$(ethtool -P "$1" | sed -e 's/Permanent address: //') addr=$(ethtool -P "$1" | sed -e 's/Permanent address: //')
if [[ -z "$addr" ]] || [[ "$addr" = "00:00:00:00:00:00" ]] if [[ -z $addr ]] || [[ $addr == "00:00:00:00:00:00" ]]; then
then
derror "Can't get the permanent address of $1" derror "Can't get the permanent address of $1"
else else
echo "$addr" echo "$addr"
@ -391,13 +387,13 @@ kdump_setup_bond() {
_bondoptions=$(get_nmcli_value_by_field "$_nm_show_cmd" "bond.options") _bondoptions=$(get_nmcli_value_by_field "$_nm_show_cmd" "bond.options")
if [[ -z "$_bondoptions" ]]; then if [[ -z $_bondoptions ]]; then
dwarning "Failed to get bond configuration via nmlci output. Now try sourcing ifcfg script." dwarning "Failed to get bond configuration via nmlci output. Now try sourcing ifcfg script."
source_ifcfg_file "$_netdev" source_ifcfg_file "$_netdev"
_bondoptions="$(echo "$BONDING_OPTS" | xargs echo | tr " " ",")" _bondoptions="$(echo "$BONDING_OPTS" | xargs echo | tr " " ",")"
fi fi
if [[ -z "$_bondoptions" ]]; then if [[ -z $_bondoptions ]]; then
derror "Get empty bond options" derror "Get empty bond options"
exit 1 exit 1
fi fi
@ -456,10 +452,9 @@ find_online_znet_device() {
local CCWGROUPBUS_DEVICEDIR="/sys/bus/ccwgroup/devices" local CCWGROUPBUS_DEVICEDIR="/sys/bus/ccwgroup/devices"
local NETWORK_DEVICES d ifname ONLINE local NETWORK_DEVICES d ifname ONLINE
[[ ! -d "$CCWGROUPBUS_DEVICEDIR" ]] && return [[ ! -d $CCWGROUPBUS_DEVICEDIR ]] && return
NETWORK_DEVICES=$(find $CCWGROUPBUS_DEVICEDIR) NETWORK_DEVICES=$(find $CCWGROUPBUS_DEVICEDIR)
for d in $NETWORK_DEVICES for d in $NETWORK_DEVICES; do
do
[[ ! -f "$d/online" ]] && continue [[ ! -f "$d/online" ]] && continue
read -r ONLINE < "$d/online" read -r ONLINE < "$d/online"
if [[ $ONLINE -ne 1 ]]; then if [[ $ONLINE -ne 1 ]]; then
@ -467,14 +462,12 @@ find_online_znet_device() {
fi fi
# determine interface name, if there (only for qeth and if # determine interface name, if there (only for qeth and if
# device is online) # device is online)
if [[ -f $d/if_name ]] if [[ -f $d/if_name ]]; then
then
read -r ifname < "$d/if_name" read -r ifname < "$d/if_name"
elif [[ -d $d/net ]] elif [[ -d $d/net ]]; then
then
ifname=$(ls "$d/net/") ifname=$(ls "$d/net/")
fi fi
[[ -n "$ifname" ]] && break [[ -n $ifname ]] && break
done done
echo -n "$ifname" echo -n "$ifname"
} }
@ -494,7 +487,7 @@ kdump_setup_znet() {
SUBCHANNELS=$(get_nmcli_value_by_field "$_nmcli_cmd" "${s390_prefix}subchannels") SUBCHANNELS=$(get_nmcli_value_by_field "$_nmcli_cmd" "${s390_prefix}subchannels")
_options=$(get_nmcli_value_by_field "$_nmcli_cmd" "${s390_prefix}options") _options=$(get_nmcli_value_by_field "$_nmcli_cmd" "${s390_prefix}options")
if [[ -z "$NETTYPE" || -z "$SUBCHANNELS" || -z "$_options" ]]; then if [[ -z $NETTYPE || -z $SUBCHANNELS || -z $_options ]]; then
dwarning "Failed to get znet configuration via nmlci output. Now try sourcing ifcfg script." dwarning "Failed to get znet configuration via nmlci output. Now try sourcing ifcfg script."
source_ifcfg_file "$_netdev" source_ifcfg_file "$_netdev"
for i in $OPTIONS; do for i in $OPTIONS; do
@ -502,15 +495,14 @@ kdump_setup_znet() {
done done
fi fi
if [[ -z "$NETTYPE" || -z "$SUBCHANNELS" || -z "$_options" ]]; then if [[ -z $NETTYPE || -z $SUBCHANNELS || -z $_options ]]; then
exit 1 exit 1
fi fi
echo "rd.znet=${NETTYPE},${SUBCHANNELS},${_options} rd.znet_ifname=$_netdev:${SUBCHANNELS}" > "${initdir}/etc/cmdline.d/30znet.conf" echo "rd.znet=${NETTYPE},${SUBCHANNELS},${_options} rd.znet_ifname=$_netdev:${SUBCHANNELS}" > "${initdir}/etc/cmdline.d/30znet.conf"
} }
kdump_get_ip_route() kdump_get_ip_route() {
{
local _route local _route
if ! _route=$(/sbin/ip -o route get to "$1" 2>&1); then if ! _route=$(/sbin/ip -o route get to "$1" 2>&1); then
derror "Bad kdump network destination: $1" derror "Bad kdump network destination: $1"
@ -519,18 +511,16 @@ kdump_get_ip_route()
echo "$_route" echo "$_route"
} }
kdump_get_ip_route_field() kdump_get_ip_route_field() {
{
echo "$1" | sed -n -e "s/^.*\<$2\>\s\+\(\S\+\).*$/\1/p" echo "$1" | sed -n -e "s/^.*\<$2\>\s\+\(\S\+\).*$/\1/p"
} }
kdump_get_remote_ip() kdump_get_remote_ip() {
{
local _remote _remote_temp local _remote _remote_temp
_remote=$(get_remote_host "$1") _remote=$(get_remote_host "$1")
if is_hostname "$_remote"; then if is_hostname "$_remote"; then
_remote_temp=$(getent ahosts "$_remote" | grep -v : | head -n 1) _remote_temp=$(getent ahosts "$_remote" | grep -v : | head -n 1)
if [[ -z "$_remote_temp" ]]; then if [[ -z $_remote_temp ]]; then
_remote_temp=$(getent ahosts "$_remote" | head -n 1) _remote_temp=$(getent ahosts "$_remote" | head -n 1)
fi fi
_remote=$(echo "$_remote_temp" | awk '{print $1}') _remote=$(echo "$_remote_temp" | awk '{print $1}')
@ -555,7 +545,7 @@ kdump_install_net() {
kdumpnic=$(kdump_setup_ifname "$_netdev") kdumpnic=$(kdump_setup_ifname "$_netdev")
_znet_netdev=$(find_online_znet_device) _znet_netdev=$(find_online_znet_device)
if [[ -n "$_znet_netdev" ]]; then if [[ -n $_znet_netdev ]]; then
_nm_show_cmd_znet=$(get_nmcli_connection_show_cmd_by_ifname "$_znet_netdev") _nm_show_cmd_znet=$(get_nmcli_connection_show_cmd_by_ifname "$_znet_netdev")
if ! (kdump_setup_znet "$_znet_netdev" "$_nm_show_cmd_znet"); then if ! (kdump_setup_znet "$_znet_netdev" "$_nm_show_cmd_znet"); then
derror "Failed to set up znet" derror "Failed to set up znet"
@ -564,7 +554,7 @@ kdump_install_net() {
fi fi
_static=$(kdump_static_ip "$_netdev" "$_srcaddr" "$kdumpnic") _static=$(kdump_static_ip "$_netdev" "$_srcaddr" "$kdumpnic")
if [[ -n "$_static" ]]; then if [[ -n $_static ]]; then
_proto=none _proto=none
elif is_ipv6_address "$_srcaddr"; then elif is_ipv6_address "$_srcaddr"; then
_proto=auto6 _proto=auto6
@ -579,8 +569,8 @@ kdump_install_net() {
# so we have to avoid adding duplicates # so we have to avoid adding duplicates
# We should also check /proc/cmdline for existing ip=xx arg. # We should also check /proc/cmdline for existing ip=xx arg.
# For example, iscsi boot will specify ip=xxx arg in cmdline. # For example, iscsi boot will specify ip=xxx arg in cmdline.
if [[ ! -f $_ip_conf ]] || ! grep -q "$_ip_opts" "$_ip_conf" &&\ if [[ ! -f $_ip_conf ]] || ! grep -q "$_ip_opts" "$_ip_conf" \
! grep -q "ip=[^[:space:]]*$_netdev" /proc/cmdline; then && ! grep -q "ip=[^[:space:]]*$_netdev" /proc/cmdline; then
echo "$_ip_opts" >> "$_ip_conf" echo "$_ip_opts" >> "$_ip_conf"
fi fi
@ -611,8 +601,8 @@ kdump_install_net() {
# the default gate way for network dump, eth1 in the fence kdump path will # the default gate way for network dump, eth1 in the fence kdump path will
# call kdump_install_net again and we don't want eth1 to be the default # call kdump_install_net again and we don't want eth1 to be the default
# gateway. # gateway.
if [[ ! -f ${initdir}/etc/cmdline.d/60kdumpnic.conf ]] && if [[ ! -f ${initdir}/etc/cmdline.d/60kdumpnic.conf ]] \
[[ ! -f ${initdir}/etc/cmdline.d/70bootdev.conf ]]; then && [[ ! -f ${initdir}/etc/cmdline.d/70bootdev.conf ]]; then
echo "kdumpnic=$kdumpnic" > "${initdir}/etc/cmdline.d/60kdumpnic.conf" echo "kdumpnic=$kdumpnic" > "${initdir}/etc/cmdline.d/60kdumpnic.conf"
echo "bootdev=$kdumpnic" > "${initdir}/etc/cmdline.d/70bootdev.conf" echo "bootdev=$kdumpnic" > "${initdir}/etc/cmdline.d/70bootdev.conf"
fi fi
@ -622,7 +612,7 @@ kdump_install_net() {
kdump_install_pre_post_conf() { kdump_install_pre_post_conf() {
if [[ -d /etc/kdump/pre.d ]]; then if [[ -d /etc/kdump/pre.d ]]; then
for file in /etc/kdump/pre.d/*; do for file in /etc/kdump/pre.d/*; do
if [[ -x "$file" ]]; then if [[ -x $file ]]; then
dracut_install "$file" dracut_install "$file"
elif [[ $file != "/etc/kdump/pre.d/*" ]]; then elif [[ $file != "/etc/kdump/pre.d/*" ]]; then
echo "$file is not executable" echo "$file is not executable"
@ -632,7 +622,7 @@ kdump_install_pre_post_conf() {
if [[ -d /etc/kdump/post.d ]]; then if [[ -d /etc/kdump/post.d ]]; then
for file in /etc/kdump/post.d/*; do for file in /etc/kdump/post.d/*; do
if [[ -x "$file" ]]; then if [[ -x $file ]]; then
dracut_install "$file" dracut_install "$file"
elif [[ $file != "/etc/kdump/post.d/*" ]]; then elif [[ $file != "/etc/kdump/post.d/*" ]]; then
echo "$file is not executable" echo "$file is not executable"
@ -641,8 +631,7 @@ kdump_install_pre_post_conf() {
fi fi
} }
default_dump_target_install_conf() default_dump_target_install_conf() {
{
local _target _fstype local _target _fstype
local _mntpoint _save_path local _mntpoint _save_path
@ -663,7 +652,7 @@ default_dump_target_install_conf()
echo "$_fstype $_target" >> "${initdir}/tmp/$$-kdump.conf" echo "$_fstype $_target" >> "${initdir}/tmp/$$-kdump.conf"
# don't touch the path under root mount # don't touch the path under root mount
if [[ "$_mntpoint" != "/" ]]; then if [[ $_mntpoint != "/" ]]; then
_save_path=${_save_path##"$_mntpoint"} _save_path=${_save_path##"$_mntpoint"}
fi fi
@ -678,8 +667,7 @@ kdump_install_conf() {
kdump_read_conf > "${initdir}/tmp/$$-kdump.conf" kdump_read_conf > "${initdir}/tmp/$$-kdump.conf"
while read -r _opt _val; while read -r _opt _val; do
do
# remove inline comments after the end of a directive. # remove inline comments after the end of a directive.
case "$_opt" in case "$_opt" in
raw) raw)
@ -694,7 +682,7 @@ kdump_install_conf() {
kdump_install_net "$_val" kdump_install_net "$_val"
;; ;;
dracut_args) dracut_args)
if [[ $(get_dracut_args_fstype "$_val") = nfs* ]] ; then if [[ $(get_dracut_args_fstype "$_val") == nfs* ]]; then
kdump_install_net "$(get_dracut_args_target "$_val")" kdump_install_net "$(get_dracut_args_target "$_val")"
fi fi
;; ;;
@ -744,16 +732,17 @@ kdump_get_iscsi_initiator() {
local _initiator local _initiator
local initiator_conf="/etc/iscsi/initiatorname.iscsi" local initiator_conf="/etc/iscsi/initiatorname.iscsi"
[[ -f "$initiator_conf" ]] || return 1 [[ -f $initiator_conf ]] || return 1
while read -r _initiator; do while read -r _initiator; do
[[ -z "${_initiator%%#*}" ]] && continue # Skip comment lines [[ -z ${_initiator%%#*} ]] && continue # Skip comment lines
case $_initiator in case $_initiator in
InitiatorName=*) InitiatorName=*)
initiator=${_initiator#InitiatorName=} initiator=${_initiator#InitiatorName=}
echo "rd.iscsi.initiator=${initiator}" echo "rd.iscsi.initiator=${initiator}"
return 0;; return 0
;;
*) ;; *) ;;
esac esac
done < ${initiator_conf} done < ${initiator_conf}
@ -763,15 +752,21 @@ kdump_get_iscsi_initiator() {
# Figure out iBFT session according to session type # Figure out iBFT session according to session type
is_ibft() { is_ibft() {
[[ "$(kdump_iscsi_get_rec_val "$1" "node.discovery_type")" = fw ]] [[ "$(kdump_iscsi_get_rec_val "$1" "node.discovery_type")" == fw ]]
} }
kdump_setup_iscsi_device() { kdump_setup_iscsi_device() {
local path=$1 local path=$1
local tgt_name; local tgt_ipaddr; local tgt_name
local username; local password; local userpwd_str; local tgt_ipaddr
local username_in; local password_in; local userpwd_in_str; local username
local netroot_str ; local initiator_str; local password
local userpwd_str
local username_in
local password_in
local userpwd_in_str
local netroot_str
local initiator_str
local netroot_conf="${initdir}/etc/cmdline.d/50iscsi.conf" local netroot_conf="${initdir}/etc/cmdline.d/50iscsi.conf"
local initiator_conf="/etc/iscsi/initiatorname.iscsi" local initiator_conf="/etc/iscsi/initiatorname.iscsi"
@ -796,18 +791,18 @@ kdump_setup_iscsi_device() {
# get and set username and password details # get and set username and password details
username=$(kdump_iscsi_get_rec_val "$path" "node.session.auth.username") username=$(kdump_iscsi_get_rec_val "$path" "node.session.auth.username")
[[ "$username" == "<empty>" ]] && username="" [[ $username == "<empty>" ]] && username=""
password=$(kdump_iscsi_get_rec_val "$path" "node.session.auth.password") password=$(kdump_iscsi_get_rec_val "$path" "node.session.auth.password")
[[ "$password" == "<empty>" ]] && password="" [[ $password == "<empty>" ]] && password=""
username_in=$(kdump_iscsi_get_rec_val "$path" "node.session.auth.username_in") username_in=$(kdump_iscsi_get_rec_val "$path" "node.session.auth.username_in")
[[ -n "$username" ]] && userpwd_str="$username:$password" [[ -n $username ]] && userpwd_str="$username:$password"
# get and set incoming username and password details # get and set incoming username and password details
[[ "$username_in" == "<empty>" ]] && username_in="" [[ $username_in == "<empty>" ]] && username_in=""
password_in=$(kdump_iscsi_get_rec_val "$path" "node.session.auth.password_in") password_in=$(kdump_iscsi_get_rec_val "$path" "node.session.auth.password_in")
[[ "$password_in" == "<empty>" ]] && password_in="" [[ $password_in == "<empty>" ]] && password_in=""
[[ -n "$username_in" ]] && userpwd_in_str=":$username_in:$password_in" [[ -n $username_in ]] && userpwd_in_str=":$username_in:$password_in"
kdump_install_net "$tgt_ipaddr" kdump_install_net "$tgt_ipaddr"
@ -869,8 +864,7 @@ get_alias() {
local alias_set local alias_set
ips=$(hostname -I) ips=$(hostname -I)
for ip in $ips for ip in $ips; do
do
# in /etc/hosts, alias can come at the 2nd column # in /etc/hosts, alias can come at the 2nd column
if entries=$(grep "$ip" /etc/hosts | awk '{ $1=""; print $0 }'); then if entries=$(grep "$ip" /etc/hosts | awk '{ $1=""; print $0 }'); then
alias_set="$alias_set $entries" alias_set="$alias_set $entries"
@ -892,7 +886,7 @@ is_localhost() {
hostnames="$hostnames $shortnames $aliasname" hostnames="$hostnames $shortnames $aliasname"
for name in ${hostnames}; do for name in ${hostnames}; do
if [[ "$name" == "$nodename" ]]; then if [[ $name == "$nodename" ]]; then
return 0 return 0
fi fi
done done
@ -963,7 +957,7 @@ kdump_configure_fence_kdump () {
echo "fence_kdump_nodes $nodes" >> "${kdump_cfg_file}" echo "fence_kdump_nodes $nodes" >> "${kdump_cfg_file}"
args=$(get_pcs_fence_kdump_args) args=$(get_pcs_fence_kdump_args)
if [[ -n "$args" ]]; then if [[ -n $args ]]; then
echo "fence_kdump_args $args" >> "${kdump_cfg_file}" echo "fence_kdump_args $args" >> "${kdump_cfg_file}"
fi fi

158
kdumpctl
View File

@ -149,7 +149,7 @@ rebuild_initrd()
check_exist() check_exist()
{ {
for file in $1; do for file in $1; do
if [[ ! -e "$file" ]]; then if [[ ! -e $file ]]; then
derror "Error: $file not found." derror "Error: $file not found."
return 1 return 1
fi fi
@ -160,7 +160,7 @@ check_exist()
check_executable() check_executable()
{ {
for file in $1; do for file in $1; do
if [[ ! -x "$file" ]]; then if [[ ! -x $file ]]; then
derror "Error: $file is not executable." derror "Error: $file is not executable."
return 1 return 1
fi fi
@ -171,7 +171,7 @@ backup_default_initrd()
{ {
ddebug "backup default initrd: $DEFAULT_INITRD" ddebug "backup default initrd: $DEFAULT_INITRD"
if [[ ! -f "$DEFAULT_INITRD" ]]; then if [[ ! -f $DEFAULT_INITRD ]]; then
return return
fi fi
@ -190,7 +190,7 @@ restore_default_initrd()
{ {
ddebug "restore default initrd: $DEFAULT_INITRD" ddebug "restore default initrd: $DEFAULT_INITRD"
if [[ ! -f "$DEFAULT_INITRD" ]]; then if [[ ! -f $DEFAULT_INITRD ]]; then
return return
fi fi
@ -200,7 +200,7 @@ restore_default_initrd()
# verify checksum before restoring # verify checksum before restoring
backup_checksum=$(sha1sum "$DEFAULT_INITRD_BAK" | awk '{ print $1 }') backup_checksum=$(sha1sum "$DEFAULT_INITRD_BAK" | awk '{ print $1 }')
default_checksum=$(awk '{ print $1 }' "$INITRD_CHECKSUM_LOCATION") default_checksum=$(awk '{ print $1 }' "$INITRD_CHECKSUM_LOCATION")
if [[ "$default_checksum" != "$backup_checksum" ]]; then if [[ $default_checksum != "$backup_checksum" ]]; then
dwarn "WARNING: checksum mismatch! Can't restore original initrd.." dwarn "WARNING: checksum mismatch! Can't restore original initrd.."
else else
rm -f $INITRD_CHECKSUM_LOCATION rm -f $INITRD_CHECKSUM_LOCATION
@ -220,7 +220,7 @@ check_config()
dracut_args) dracut_args)
if [[ $config_val == *--mount* ]]; then if [[ $config_val == *--mount* ]]; then
if [[ $(echo "$config_val" | grep -o "\-\-mount" | wc -l) -ne 1 ]]; then if [[ $(echo "$config_val" | grep -o "\-\-mount" | wc -l) -ne 1 ]]; then
derror "Multiple mount targets specified in one \"dracut_args\"." derror 'Multiple mount targets specified in one "dracut_args".'
return 1 return 1
fi fi
config_opt=_target config_opt=_target
@ -235,8 +235,8 @@ check_config()
ext[234] | minix | btrfs | xfs | nfs | ssh) ext[234] | minix | btrfs | xfs | nfs | ssh)
config_opt=_target config_opt=_target
;; ;;
sshkey|path|core_collector|kdump_post|kdump_pre|extra_bins|extra_modules|failure_action|default|final_action|force_rebuild|force_no_rebuild|fence_kdump_args|fence_kdump_nodes) sshkey | path | core_collector | kdump_post | kdump_pre | extra_bins | extra_modules | failure_action | default | final_action | force_rebuild | force_no_rebuild | fence_kdump_args | fence_kdump_nodes) ;;
;;
net | options | link_delay | disk_timeout | debug_mem_level | blacklist) net | options | link_delay | disk_timeout | debug_mem_level | blacklist)
derror "Deprecated kdump config option: $config_opt. Refer to kdump.conf manpage for alternatives." derror "Deprecated kdump config option: $config_opt. Refer to kdump.conf manpage for alternatives."
return 1 return 1
@ -250,12 +250,12 @@ check_config()
;; ;;
esac esac
if [[ -z "$config_val" ]]; then if [[ -z $config_val ]]; then
derror "Invalid kdump config value for option '$config_opt'" derror "Invalid kdump config value for option '$config_opt'"
return 1 return 1
fi fi
if [[ -n "${_opt_rec[$config_opt]}" ]]; then if [[ -n ${_opt_rec[$config_opt]} ]]; then
if [[ $config_opt == _target ]]; then if [[ $config_opt == _target ]]; then
derror "More than one dump targets specified" derror "More than one dump targets specified"
else else
@ -291,7 +291,7 @@ get_pcs_cluster_modified_files()
if [[ -f $FENCE_KDUMP_CONFIG_FILE ]]; then if [[ -f $FENCE_KDUMP_CONFIG_FILE ]]; then
time_stamp=$(stat -c "%Y" "$FENCE_KDUMP_CONFIG_FILE") time_stamp=$(stat -c "%Y" "$FENCE_KDUMP_CONFIG_FILE")
if [[ "$time_stamp" -gt "$image_time" ]]; then if [[ $time_stamp -gt $image_time ]]; then
modified_files="$modified_files $FENCE_KDUMP_CONFIG_FILE" modified_files="$modified_files $FENCE_KDUMP_CONFIG_FILE"
fi fi
fi fi
@ -335,14 +335,14 @@ check_files_modified()
HOOKS="/etc/kdump/post.d/ /etc/kdump/pre.d/" HOOKS="/etc/kdump/post.d/ /etc/kdump/pre.d/"
if [[ -d /etc/kdump/post.d ]]; then if [[ -d /etc/kdump/post.d ]]; then
for file in /etc/kdump/post.d/*; do for file in /etc/kdump/post.d/*; do
if [[ -x "$file" ]]; then if [[ -x $file ]]; then
POST_FILES="$POST_FILES $file" POST_FILES="$POST_FILES $file"
fi fi
done done
fi fi
if [[ -d /etc/kdump/pre.d ]]; then if [[ -d /etc/kdump/pre.d ]]; then
for file in /etc/kdump/pre.d/*; do for file in /etc/kdump/pre.d/*; do
if [[ -x "$file" ]]; then if [[ -x $file ]]; then
PRE_FILES="$PRE_FILES $file" PRE_FILES="$PRE_FILES $file"
fi fi
done done
@ -359,7 +359,7 @@ check_files_modified()
# Check for any updated extra module # Check for any updated extra module
EXTRA_MODULES="$(kdump_get_conf_val extra_modules)" EXTRA_MODULES="$(kdump_get_conf_val extra_modules)"
if [[ -n "$EXTRA_MODULES" ]]; then if [[ -n $EXTRA_MODULES ]]; then
if [[ -e /lib/modules/$KDUMP_KERNELVER/modules.dep ]]; then if [[ -e /lib/modules/$KDUMP_KERNELVER/modules.dep ]]; then
files="$files /lib/modules/$KDUMP_KERNELVER/modules.dep" files="$files /lib/modules/$KDUMP_KERNELVER/modules.dep"
fi fi
@ -383,15 +383,15 @@ check_files_modified()
check_exist "$files" && check_executable "$EXTRA_BINS" || return 2 check_exist "$files" && check_executable "$EXTRA_BINS" || return 2
for file in $files; do for file in $files; do
if [[ -e "$file" ]]; then if [[ -e $file ]]; then
time_stamp=$(stat -c "%Y" "$file") time_stamp=$(stat -c "%Y" "$file")
if [[ "$time_stamp" -gt "$image_time" ]]; then if [[ $time_stamp -gt $image_time ]]; then
modified_files="$modified_files $file" modified_files="$modified_files $file"
fi fi
if [[ -L "$file" ]]; then if [[ -L $file ]]; then
file=$(readlink -m "$file") file=$(readlink -m "$file")
time_stamp=$(stat -c "%Y" "$file") time_stamp=$(stat -c "%Y" "$file")
if [[ "$time_stamp" -gt "$image_time" ]]; then if [[ $time_stamp -gt $image_time ]]; then
modified_files="$modified_files $file" modified_files="$modified_files $file"
fi fi
fi fi
@ -400,7 +400,7 @@ check_files_modified()
fi fi
done done
if [[ -n "$modified_files" ]]; then if [[ -n $modified_files ]]; then
dinfo "Detected change(s) in the following file(s): $modified_files" dinfo "Detected change(s) in the following file(s): $modified_files"
return 1 return 1
fi fi
@ -414,8 +414,9 @@ check_drivers_modified()
# If it's dump target is on block device, detect the block driver # If it's dump target is on block device, detect the block driver
_target=$(get_block_dump_target) _target=$(get_block_dump_target)
if [[ -n "$_target" ]]; then if [[ -n $_target ]]; then
_record_block_drivers() { _record_block_drivers()
{
local _drivers local _drivers
_drivers=$(udevadm info -a "/dev/block/$1" | sed -n 's/\s*DRIVERS=="\(\S\+\)"/\1/p') _drivers=$(udevadm info -a "/dev/block/$1" | sed -n 's/\s*DRIVERS=="\(\S\+\)"/\1/p')
for _driver in $_drivers; do for _driver in $_drivers; do
@ -431,7 +432,7 @@ check_drivers_modified()
# Include watchdog drivers if watchdog module is not omitted # Include watchdog drivers if watchdog module is not omitted
is_dracut_mod_omitted watchdog || _new_drivers+=" $(get_watchdog_drvs)" is_dracut_mod_omitted watchdog || _new_drivers+=" $(get_watchdog_drvs)"
[[ -z "$_new_drivers" ]] && return 0 [[ -z $_new_drivers ]] && return 0
if is_fadump_capable; then if is_fadump_capable; then
_old_drivers="$(lsinitrd "$TARGET_INITRD" -f /usr/lib/dracut/fadump-kernel-modules.txt | tr '\n' ' ')" _old_drivers="$(lsinitrd "$TARGET_INITRD" -f /usr/lib/dracut/fadump-kernel-modules.txt | tr '\n' ' ')"
@ -445,7 +446,7 @@ check_drivers_modified()
# Skip deprecated/invalid driver name or built-in module # Skip deprecated/invalid driver name or built-in module
_module_name=$(modinfo --set-version "$KDUMP_KERNELVER" -F name "$_driver" 2> /dev/null) _module_name=$(modinfo --set-version "$KDUMP_KERNELVER" -F name "$_driver" 2> /dev/null)
_module_filename=$(modinfo --set-version "$KDUMP_KERNELVER" -n "$_driver" 2> /dev/null) _module_filename=$(modinfo --set-version "$KDUMP_KERNELVER" -n "$_driver" 2> /dev/null)
if [[ -z "$_module_name" ]] || [[ -z "$_module_filename" ]] || [[ "$_module_filename" = *"(builtin)"* ]]; then if [[ -z $_module_name ]] || [[ -z $_module_filename ]] || [[ $_module_filename == *"(builtin)"* ]]; then
continue continue
fi fi
if ! [[ " $_old_drivers " == *" $_module_name "* ]]; then if ! [[ " $_old_drivers " == *" $_module_name "* ]]; then
@ -474,21 +475,21 @@ check_fs_modified()
_target=$(get_block_dump_target) _target=$(get_block_dump_target)
_new_fstype=$(get_fs_type_from_target "$_target") _new_fstype=$(get_fs_type_from_target "$_target")
if [[ -z "$_target" ]] || [[ -z "$_new_fstype" ]];then if [[ -z $_target ]] || [[ -z $_new_fstype ]]; then
derror "Dump target is invalid" derror "Dump target is invalid"
return 2 return 2
fi fi
ddebug "_target=$_target _new_fstype=$_new_fstype" ddebug "_target=$_target _new_fstype=$_new_fstype"
_new_dev=$(kdump_get_persistent_dev "$_target") _new_dev=$(kdump_get_persistent_dev "$_target")
if [[ -z "$_new_dev" ]]; then if [[ -z $_new_dev ]]; then
perror "Get persistent device name failed" perror "Get persistent device name failed"
return 2 return 2
fi fi
_new_mntpoint="$(get_kdump_mntpoint_from_target "$_target")" _new_mntpoint="$(get_kdump_mntpoint_from_target "$_target")"
_dracut_args=$(lsinitrd "$TARGET_INITRD" -f usr/lib/dracut/build-parameter.txt) _dracut_args=$(lsinitrd "$TARGET_INITRD" -f usr/lib/dracut/build-parameter.txt)
if [[ -z "$_dracut_args" ]];then if [[ -z $_dracut_args ]]; then
dwarn "Warning: No dracut arguments found in initrd" dwarn "Warning: No dracut arguments found in initrd"
return 0 return 0
fi fi
@ -501,10 +502,10 @@ check_fs_modified()
_old_dev=$1 _old_dev=$1
_old_mntpoint=$2 _old_mntpoint=$2
_old_fstype=$3 _old_fstype=$3
[[ $_new_dev = "$_old_dev" && $_new_mntpoint = "$_old_mntpoint" && $_new_fstype = "$_old_fstype" ]] && return 0 [[ $_new_dev == "$_old_dev" && $_new_mntpoint == "$_old_mntpoint" && $_new_fstype == "$_old_fstype" ]] && return 0
# otherwise rebuild if target device is not a root device # otherwise rebuild if target device is not a root device
else else
[[ "$_target" = "$(get_root_fs_device)" ]] && return 0 [[ $_target == "$(get_root_fs_device)" ]] && return 0
fi fi
dinfo "Detected change in File System" dinfo "Detected change in File System"
@ -551,25 +552,25 @@ check_rebuild()
force_no_rebuild=$(kdump_get_conf_val force_no_rebuild) force_no_rebuild=$(kdump_get_conf_val force_no_rebuild)
force_no_rebuild=${force_no_rebuild:-0} force_no_rebuild=${force_no_rebuild:-0}
if [[ "$force_no_rebuild" != "0" ]] && [[ "$force_no_rebuild" != "1" ]];then if [[ $force_no_rebuild != "0" ]] && [[ $force_no_rebuild != "1" ]]; then
derror "Error: force_no_rebuild value is invalid" derror "Error: force_no_rebuild value is invalid"
return 1 return 1
fi fi
force_rebuild=$(kdump_get_conf_val force_rebuild) force_rebuild=$(kdump_get_conf_val force_rebuild)
force_rebuild=${force_rebuild:-0} force_rebuild=${force_rebuild:-0}
if [[ "$force_rebuild" != "0" ]] && [[ "$force_rebuild" != "1" ]];then if [[ $force_rebuild != "0" ]] && [[ $force_rebuild != "1" ]]; then
derror "Error: force_rebuild value is invalid" derror "Error: force_rebuild value is invalid"
return 1 return 1
fi fi
if [[ "$force_no_rebuild" == "1" && "$force_rebuild" == "1" ]]; then if [[ $force_no_rebuild == "1" && $force_rebuild == "1" ]]; then
derror "Error: force_rebuild and force_no_rebuild are enabled simultaneously in kdump.conf" derror "Error: force_rebuild and force_no_rebuild are enabled simultaneously in kdump.conf"
return 1 return 1
fi fi
# Will not rebuild kdump initrd # Will not rebuild kdump initrd
if [[ "$force_no_rebuild" == "1" ]]; then if [[ $force_no_rebuild == "1" ]]; then
return 0 return 0
fi fi
@ -580,7 +581,7 @@ check_rebuild()
#in case of fadump mode, check whether the default/target #in case of fadump mode, check whether the default/target
#initrd is already built with dump capture capability #initrd is already built with dump capture capability
if [[ "$DEFAULT_DUMP_MODE" == "fadump" ]]; then if [[ $DEFAULT_DUMP_MODE == "fadump" ]]; then
capture_capable_initrd=$(lsinitrd -f $DRACUT_MODULES_FILE "$TARGET_INITRD" | grep -c -e ^kdumpbase$ -e ^zz-fadumpinit$) capture_capable_initrd=$(lsinitrd -f $DRACUT_MODULES_FILE "$TARGET_INITRD" | grep -c -e ^kdumpbase$ -e ^zz-fadumpinit$)
fi fi
fi fi
@ -595,11 +596,11 @@ check_rebuild()
if [[ $image_time -eq 0 ]]; then if [[ $image_time -eq 0 ]]; then
dinfo "No kdump initial ramdisk found." dinfo "No kdump initial ramdisk found."
elif [[ "$capture_capable_initrd" == "0" ]]; then elif [[ $capture_capable_initrd == "0" ]]; then
dinfo "Rebuild $TARGET_INITRD with dump capture support" dinfo "Rebuild $TARGET_INITRD with dump capture support"
elif [[ "$force_rebuild" != "0" ]]; then elif [[ $force_rebuild != "0" ]]; then
dinfo "Force rebuild $TARGET_INITRD" dinfo "Force rebuild $TARGET_INITRD"
elif [[ "$system_modified" != "0" ]]; then elif [[ $system_modified != "0" ]]; then
: :
else else
return 0 return 0
@ -631,7 +632,7 @@ function load_kdump_kernel_key()
# to be idempotent and so as to reduce the potential for confusion. # to be idempotent and so as to reduce the potential for confusion.
function remove_kdump_kernel_key() function remove_kdump_kernel_key()
{ {
if [[ -z "$KDUMP_KEY_ID" ]]; then if [[ -z $KDUMP_KEY_ID ]]; then
return return
fi fi
@ -696,7 +697,7 @@ check_ssh_config()
case "$config_opt" in case "$config_opt" in
sshkey) sshkey)
# remove inline comments after the end of a directive. # remove inline comments after the end of a directive.
if [[ -f "$config_val" ]]; then if [[ -f $config_val ]]; then
# canonicalize the path # canonicalize the path
SSH_KEY_LOCATION=$(/usr/bin/readlink -m "$config_val") SSH_KEY_LOCATION=$(/usr/bin/readlink -m "$config_val")
else else
@ -709,14 +710,14 @@ check_ssh_config()
ssh) ssh)
DUMP_TARGET=$config_val DUMP_TARGET=$config_val
;; ;;
*) *) ;;
;;
esac esac
done <<< "$(kdump_read_conf)" done <<< "$(kdump_read_conf)"
#make sure they've configured kdump.conf for ssh dumps #make sure they've configured kdump.conf for ssh dumps
SSH_TARGET=$(echo -n "$DUMP_TARGET" | sed -n '/.*@/p') SSH_TARGET=$(echo -n "$DUMP_TARGET" | sed -n '/.*@/p')
if [[ -z "$SSH_TARGET" ]]; then if [[ -z $SSH_TARGET ]]; then
return 1 return 1
fi fi
return 0 return 0
@ -763,7 +764,7 @@ check_and_wait_network_ready()
diff=$((cur - start_time)) diff=$((cur - start_time))
# 60s time out # 60s time out
if [[ $diff -gt 180 ]]; then if [[ $diff -gt 180 ]]; then
break; break
fi fi
sleep 1 sleep 1
done done
@ -848,8 +849,8 @@ save_raw()
local raw_target local raw_target
raw_target=$(kdump_get_conf_val raw) raw_target=$(kdump_get_conf_val raw)
[[ -z "$raw_target" ]] && return 0 [[ -z $raw_target ]] && return 0
[[ -b "$raw_target" ]] || { [[ -b $raw_target ]] || {
derror "raw partition $raw_target not found" derror "raw partition $raw_target not found"
return 1 return 1
} }
@ -859,14 +860,14 @@ save_raw()
return 0 return 0
fi fi
kdump_dir=$(kdump_get_conf_val path) kdump_dir=$(kdump_get_conf_val path)
if [[ -z "${kdump_dir}" ]]; then if [[ -z ${kdump_dir} ]]; then
coredir="/var/crash/$(date +"%Y-%m-%d-%H:%M")" coredir="/var/crash/$(date +"%Y-%m-%d-%H:%M")"
else else
coredir="${kdump_dir}/$(date +"%Y-%m-%d-%H:%M")" coredir="${kdump_dir}/$(date +"%Y-%m-%d-%H:%M")"
fi fi
mkdir -p "$coredir" mkdir -p "$coredir"
[[ -d "$coredir" ]] || { [[ -d $coredir ]] || {
derror "failed to create $coredir" derror "failed to create $coredir"
return 1 return 1
} }
@ -897,11 +898,11 @@ path_to_be_relabeled()
if is_user_configured_dump_target; then if is_user_configured_dump_target; then
if is_mount_in_dracut_args; then if is_mount_in_dracut_args; then
return; return
fi fi
_target=$(local_fs_dump_target) _target=$(local_fs_dump_target)
if [[ -n "$_target" ]]; then if [[ -n $_target ]]; then
_mnt=$(get_mntpoint_from_target "$_target") _mnt=$(get_mntpoint_from_target "$_target")
if ! is_mounted "$_mnt"; then if ! is_mounted "$_mnt"; then
return return
@ -914,7 +915,7 @@ path_to_be_relabeled()
_path=$(get_save_path) _path=$(get_save_path)
# if $_path is masked by other mount, we will not relabel it. # if $_path is masked by other mount, we will not relabel it.
_rmnt=$(df "$_mnt/$_path" 2> /dev/null | tail -1 | awk '{ print $NF }') _rmnt=$(df "$_mnt/$_path" 2> /dev/null | tail -1 | awk '{ print $NF }')
if [[ "$_rmnt" == "$_mnt" ]]; then if [[ $_rmnt == "$_mnt" ]]; then
echo "$_mnt/$_path" echo "$_mnt/$_path"
fi fi
} }
@ -924,14 +925,14 @@ selinux_relabel()
local _path _i _attr local _path _i _attr
_path=$(path_to_be_relabeled) _path=$(path_to_be_relabeled)
if [[ -z "$_path" ]] || ! [[ -d "$_path" ]] ; then if [[ -z $_path ]] || ! [[ -d $_path ]]; then
return return
fi fi
while IFS= read -r -d '' _i; do while IFS= read -r -d '' _i; do
_attr=$(getfattr -m "security.selinux" "$_i" 2> /dev/null) _attr=$(getfattr -m "security.selinux" "$_i" 2> /dev/null)
if [[ -z "$_attr" ]]; then if [[ -z $_attr ]]; then
restorecon "$_i"; restorecon "$_i"
fi fi
done < <(find "$_path" -print0) done < <(find "$_path" -print0)
} }
@ -947,7 +948,7 @@ check_fence_kdump_config()
nodes=$(kdump_get_conf_val "fence_kdump_nodes") nodes=$(kdump_get_conf_val "fence_kdump_nodes")
for node in $nodes; do for node in $nodes; do
if [[ "$node" = "$hostname" ]]; then if [[ $node == "$hostname" ]]; then
derror "Option fence_kdump_nodes cannot contain $hostname" derror "Option fence_kdump_nodes cannot contain $hostname"
return 1 return 1
fi fi
@ -1003,14 +1004,14 @@ check_failure_action_config()
default_option=$(kdump_get_conf_val default) default_option=$(kdump_get_conf_val default)
failure_action=$(kdump_get_conf_val failure_action) failure_action=$(kdump_get_conf_val failure_action)
if [[ -z "$failure_action" ]] && [[ -z "$default_option" ]]; then if [[ -z $failure_action ]] && [[ -z $default_option ]]; then
return 0 return 0
elif [[ -n "$failure_action" ]] && [[ -n "$default_option" ]]; then elif [[ -n $failure_action ]] && [[ -n $default_option ]]; then
derror "Cannot specify 'failure_action' and 'default' option together" derror "Cannot specify 'failure_action' and 'default' option together"
return 1 return 1
fi fi
if [[ -n "$default_option" ]]; then if [[ -n $default_option ]]; then
option="default" option="default"
failure_action="$default_option" failure_action="$default_option"
fi fi
@ -1022,6 +1023,7 @@ check_failure_action_config()
*) *)
dinfo $"Usage kdump.conf: $option {reboot|halt|poweroff|shell|dump_to_rootfs}" dinfo $"Usage kdump.conf: $option {reboot|halt|poweroff|shell|dump_to_rootfs}"
return 1 return 1
;;
esac esac
} }
@ -1030,7 +1032,7 @@ check_final_action_config()
local final_action local final_action
final_action=$(kdump_get_conf_val final_action) final_action=$(kdump_get_conf_val final_action)
if [[ -z "$final_action" ]]; then if [[ -z $final_action ]]; then
return 0 return 0
else else
case "$final_action" in case "$final_action" in
@ -1040,6 +1042,7 @@ check_final_action_config()
*) *)
dinfo $"Usage kdump.conf: final_action {reboot|halt|poweroff}" dinfo $"Usage kdump.conf: final_action {reboot|halt|poweroff}"
return 1 return 1
;;
esac esac
fi fi
} }
@ -1187,7 +1190,8 @@ stop()
return 0 return 0
} }
rebuild() { rebuild()
{
check_config || return 1 check_config || return 1
if check_ssh_config; then if check_ssh_config; then
@ -1203,7 +1207,8 @@ rebuild() {
return $? return $?
} }
do_estimate() { do_estimate()
{
local kdump_mods local kdump_mods
local -A large_mods local -A large_mods
local baseline local baseline
@ -1211,18 +1216,18 @@ do_estimate() {
local size_mb=$((1024 * 1024)) local size_mb=$((1024 * 1024))
setup_initrd setup_initrd
if [[ ! -f "$TARGET_INITRD" ]]; then if [[ ! -f $TARGET_INITRD ]]; then
derror "kdumpctl estimate: kdump initramfs is not built yet." derror "kdumpctl estimate: kdump initramfs is not built yet."
exit 1 exit 1
fi fi
kdump_mods="$(lsinitrd "$TARGET_INITRD" -f /usr/lib/dracut/hostonly-kernel-modules.txt | tr '\n' ' ')" kdump_mods="$(lsinitrd "$TARGET_INITRD" -f /usr/lib/dracut/hostonly-kernel-modules.txt | tr '\n' ' ')"
baseline=$(kdump_get_arch_recommend_size) baseline=$(kdump_get_arch_recommend_size)
if [[ "${baseline: -1}" == "M" ]]; then if [[ ${baseline: -1} == "M" ]]; then
baseline=${baseline%M} baseline=${baseline%M}
elif [[ "${baseline: -1}" == "G" ]]; then elif [[ ${baseline: -1} == "G" ]]; then
baseline=$((${baseline%G} * 1024)) baseline=$((${baseline%G} * 1024))
elif [[ "${baseline: -1}" == "T" ]]; then elif [[ ${baseline: -1} == "T" ]]; then
baseline=$((${baseline%Y} * 1048576)) baseline=$((${baseline%Y} * 1048576))
fi fi
@ -1240,7 +1245,7 @@ do_estimate() {
# Kernel modules static size after loaded # Kernel modules static size after loaded
mod_size=0 mod_size=0
while read -r _name _size _; do while read -r _name _size _; do
if [[ ! " $kdump_mods " == *" $_name "* ]]; then if [[ " $kdump_mods " != *" $_name "* ]]; then
continue continue
fi fi
mod_size=$((mod_size + _size)) mod_size=$((mod_size + _size))
@ -1277,10 +1282,10 @@ do_estimate() {
echo "Kernel modules size: $((mod_size / size_mb))M" echo "Kernel modules size: $((mod_size / size_mb))M"
echo "Initramfs size: $((initrd_size / size_mb))M" echo "Initramfs size: $((initrd_size / size_mb))M"
echo "Runtime reservation: $((runtime_size / size_mb))M" echo "Runtime reservation: $((runtime_size / size_mb))M"
[[ $crypt_size -ne 0 ]] && \ [[ $crypt_size -ne 0 ]] &&
echo "LUKS required size: $((crypt_size / size_mb))M" echo "LUKS required size: $((crypt_size / size_mb))M"
echo -n "Large modules:" echo -n "Large modules:"
if [[ "${#large_mods[@]}" -eq 0 ]]; then if [[ ${#large_mods[@]} -eq 0 ]]; then
echo " <none>" echo " <none>"
else else
echo "" echo ""
@ -1294,14 +1299,15 @@ do_estimate() {
fi fi
} }
reset_crashkernel() { reset_crashkernel()
{
local kernel=$1 entry crashkernel_default local kernel=$1 entry crashkernel_default
local grub_etc_default="/etc/default/grub" local grub_etc_default="/etc/default/grub"
[[ -z "$kernel" ]] && kernel=$(uname -r) [[ -z $kernel ]] && kernel=$(uname -r)
crashkernel_default=$(cat "/usr/lib/modules/$kernel/crashkernel.default" 2> /dev/null) crashkernel_default=$(cat "/usr/lib/modules/$kernel/crashkernel.default" 2> /dev/null)
if [[ -z "$crashkernel_default" ]]; then if [[ -z $crashkernel_default ]]; then
derror "$kernel doesn't have a crashkernel.default" derror "$kernel doesn't have a crashkernel.default"
exit 1 exit 1
fi fi
@ -1318,7 +1324,7 @@ reset_crashkernel() {
entry=${entry#\"} entry=${entry#\"}
entry=${entry%\"} entry=${entry%\"}
if [[ -f "$grub_etc_default" ]]; then if [[ -f $grub_etc_default ]]; then
sed -i -e "s/^\(GRUB_CMDLINE_LINUX=.*\)crashkernel=[^\ \"]*\([\ \"].*\)$/\1$crashkernel_default\2/" "$grub_etc_default" sed -i -e "s/^\(GRUB_CMDLINE_LINUX=.*\)crashkernel=[^\ \"]*\([\ \"].*\)$/\1$crashkernel_default\2/" "$grub_etc_default"
fi fi
@ -1328,7 +1334,7 @@ reset_crashkernel() {
fi fi
} }
if [[ ! -f "$KDUMP_CONFIG_FILE" ]]; then if [[ ! -f $KDUMP_CONFIG_FILE ]]; then
derror "Error: No kdump config file found!" derror "Error: No kdump config file found!"
exit 1 exit 1
fi fi
@ -1375,8 +1381,8 @@ main ()
rebuild) rebuild)
rebuild rebuild
;; ;;
condrestart) condrestart) ;;
;;
propagate) propagate)
propagate_ssh_key propagate_ssh_key
;; ;;
@ -1392,6 +1398,7 @@ main ()
*) *)
dinfo $"Usage: $0 {estimate|start|stop|status|restart|reload|rebuild|reset-crashkernel|propagate|showmem}" dinfo $"Usage: $0 {estimate|start|stop|status|restart|reload|rebuild|reset-crashkernel|propagate|showmem}"
exit 1 exit 1
;;
esac esac
} }
@ -1400,6 +1407,9 @@ single_instance_lock
# To avoid fd 9 leaking, we invoke a subshell, close fd 9 and call main. # To avoid fd 9 leaking, we invoke a subshell, close fd 9 and call main.
# So that fd isn't leaking when main is invoking a subshell. # So that fd isn't leaking when main is invoking a subshell.
(exec 9<&-; main "$@") (
exec 9<&-
main "$@"
)
exit $? exit $?

View File

@ -43,20 +43,24 @@ trap '
# clean up after ourselves no matter how we die. # clean up after ourselves no matter how we die.
trap 'exit 1;' SIGINT trap 'exit 1;' SIGINT
add_dracut_arg() { add_dracut_arg()
{
dracut_args+=("$@") dracut_args+=("$@")
} }
add_dracut_mount() { add_dracut_mount()
{
add_dracut_arg "--mount" "$1" add_dracut_arg "--mount" "$1"
} }
add_dracut_sshkey() { add_dracut_sshkey()
{
add_dracut_arg "--sshkey" "$1" add_dracut_arg "--sshkey" "$1"
} }
# caller should ensure $1 is valid and mounted in 1st kernel # caller should ensure $1 is valid and mounted in 1st kernel
to_mount() { to_mount()
{
local _target=$1 _fstype=$2 _options=$3 _sed_cmd _new_mntpoint _pdev local _target=$1 _fstype=$2 _options=$3 _sed_cmd _new_mntpoint _pdev
_new_mntpoint=$(get_kdump_mntpoint_from_target "$_target") _new_mntpoint=$(get_kdump_mntpoint_from_target "$_target")
@ -64,7 +68,7 @@ to_mount() {
_options="${_options:-$(get_mntopt_from_target "$_target")}" _options="${_options:-$(get_mntopt_from_target "$_target")}"
_options="${_options:-defaults}" _options="${_options:-defaults}"
if [[ "$_fstype" == "nfs"* ]]; then if [[ $_fstype == "nfs"* ]]; then
_pdev=$_target _pdev=$_target
_sed_cmd+='s/,addr=[^,]*//;' _sed_cmd+='s/,addr=[^,]*//;'
_sed_cmd+='s/,proto=[^,]*//;' _sed_cmd+='s/,proto=[^,]*//;'
@ -94,7 +98,8 @@ to_mount() {
#Function: get_ssh_size #Function: get_ssh_size
#$1=dump target #$1=dump target
#called from while loop and shouldn't read from stdin, so we're using "ssh -n" #called from while loop and shouldn't read from stdin, so we're using "ssh -n"
get_ssh_size() { get_ssh_size()
{
local _out local _out
local _opt=("-i" "$SSH_KEY_LOCATION" "-o" "BatchMode=yes" "-o" "StrictHostKeyChecking=yes") local _opt=("-i" "$SSH_KEY_LOCATION" "-o" "BatchMode=yes" "-o" "StrictHostKeyChecking=yes")
@ -113,11 +118,11 @@ mkdir_save_path_ssh()
{ {
local _opt _dir local _opt _dir
_opt=(-i "$SSH_KEY_LOCATION" -o BatchMode=yes -o StrictHostKeyChecking=yes) _opt=(-i "$SSH_KEY_LOCATION" -o BatchMode=yes -o StrictHostKeyChecking=yes)
ssh -qn "${_opt[@]}" "$1" mkdir -p "$SAVE_PATH" &>/dev/null || \ ssh -qn "${_opt[@]}" "$1" mkdir -p "$SAVE_PATH" &> /dev/null ||
perror_exit "mkdir failed on $1:$SAVE_PATH" perror_exit "mkdir failed on $1:$SAVE_PATH"
# check whether user has write permission on $1:$SAVE_PATH # check whether user has write permission on $1:$SAVE_PATH
_dir=$(ssh -qn "${_opt[@]}" "$1" mktemp -dqp "$SAVE_PATH" 2>/dev/null) || \ _dir=$(ssh -qn "${_opt[@]}" "$1" mktemp -dqp "$SAVE_PATH" 2> /dev/null) ||
perror_exit "Could not create temporary directory on $1:$SAVE_PATH. Make sure user has write permission on destination" perror_exit "Could not create temporary directory on $1:$SAVE_PATH. Make sure user has write permission on destination"
ssh -qn "${_opt[@]}" "$1" rmdir "$_dir" ssh -qn "${_opt[@]}" "$1" rmdir "$_dir"
@ -126,20 +131,23 @@ mkdir_save_path_ssh()
#Function: get_fs_size #Function: get_fs_size
#$1=dump target #$1=dump target
get_fs_size() { get_fs_size()
{
df --output=avail "$(get_mntpoint_from_target "$1")/$SAVE_PATH" | tail -1 df --output=avail "$(get_mntpoint_from_target "$1")/$SAVE_PATH" | tail -1
} }
#Function: get_raw_size #Function: get_raw_size
#$1=dump target #$1=dump target
get_raw_size() { get_raw_size()
{
fdisk -s "$1" fdisk -s "$1"
} }
#Function: check_size #Function: check_size
#$1: dump type string ('raw', 'fs', 'ssh') #$1: dump type string ('raw', 'fs', 'ssh')
#$2: dump target #$2: dump target
check_size() { check_size()
{
local avail memtotal local avail memtotal
memtotal=$(awk '/MemTotal/{print $2}' /proc/meminfo) memtotal=$(awk '/MemTotal/{print $2}' /proc/meminfo)
@ -155,9 +163,10 @@ check_size() {
;; ;;
*) *)
return return
;;
esac || perror_exit "Check dump target size failed" esac || perror_exit "Check dump target size failed"
if [[ "$avail" -lt "$memtotal" ]]; then if [[ $avail -lt $memtotal ]]; then
dwarn "Warning: There might not be enough space to save a vmcore." dwarn "Warning: There might not be enough space to save a vmcore."
dwarn " The size of $2 should be greater than $memtotal kilo bytes." dwarn " The size of $2 should be greater than $memtotal kilo bytes."
fi fi
@ -179,13 +188,13 @@ mount_failure()
local _fstype=$3 local _fstype=$3
local msg="Failed to mount $_target" local msg="Failed to mount $_target"
if [[ -n "$_mnt" ]]; then if [[ -n $_mnt ]]; then
msg="$msg on $_mnt" msg="$msg on $_mnt"
fi fi
msg="$msg for kdump preflight check." msg="$msg for kdump preflight check."
if [[ $_fstype = "nfs" ]]; then if [[ $_fstype == "nfs" ]]; then
msg="$msg Please make sure nfs-utils has been installed." msg="$msg Please make sure nfs-utils has been installed."
fi fi
@ -201,11 +210,11 @@ check_user_configured_target()
_opt=$(get_mntopt_from_target "$_target") _opt=$(get_mntopt_from_target "$_target")
_fstype=$(get_fs_type_from_target "$_target") _fstype=$(get_fs_type_from_target "$_target")
if [[ -n "$_fstype" ]]; then if [[ -n $_fstype ]]; then
# In case of nfs4, nfs should be used instead, nfs* options is deprecated in kdump.conf # In case of nfs4, nfs should be used instead, nfs* options is deprecated in kdump.conf
[[ $_fstype = "nfs"* ]] && _fstype=nfs [[ $_fstype == "nfs"* ]] && _fstype=nfs
if [[ -n "$_cfg_fs_type" ]] && [[ "$_fstype" != "$_cfg_fs_type" ]]; then if [[ -n $_cfg_fs_type ]] && [[ $_fstype != "$_cfg_fs_type" ]]; then
perror_exit "\"$_target\" have a wrong type config \"$_cfg_fs_type\", expected \"$_fstype\"" perror_exit "\"$_target\" have a wrong type config \"$_cfg_fs_type\", expected \"$_fstype\""
fi fi
else else
@ -215,9 +224,9 @@ check_user_configured_target()
# For noauto mount, mount it inplace with default value. # For noauto mount, mount it inplace with default value.
# Else use the temporary target directory # Else use the temporary target directory
if [[ -n "$_mnt" ]]; then if [[ -n $_mnt ]]; then
if ! is_mounted "$_mnt"; then if ! is_mounted "$_mnt"; then
if [[ $_opt = *",noauto"* ]]; then if [[ $_opt == *",noauto"* ]]; then
mount "$_mnt" || mount_failure "$_target" "$_mnt" "$_fstype" mount "$_mnt" || mount_failure "$_target" "$_mnt" "$_fstype"
_mounted=$_mnt _mounted=$_mnt
else else
@ -239,17 +248,18 @@ check_user_configured_target()
check_size fs "$_target" check_size fs "$_target"
# Unmount it early, if function is interrupted and didn't reach here, the shell trap will clear it up anyway # Unmount it early, if function is interrupted and didn't reach here, the shell trap will clear it up anyway
if [[ -n "$_mounted" ]]; then if [[ -n $_mounted ]]; then
umount -f -- "$_mounted" umount -f -- "$_mounted"
fi fi
} }
# $1: core_collector config value # $1: core_collector config value
verify_core_collector() { verify_core_collector()
{
local _cmd="${1%% *}" local _cmd="${1%% *}"
local _params="${1#* }" local _params="${1#* }"
if [[ "$_cmd" != "makedumpfile" ]]; then if [[ $_cmd != "makedumpfile" ]]; then
if is_raw_dump_target; then if is_raw_dump_target; then
dwarn "Warning: specifying a non-makedumpfile core collector, you will have to recover the vmcore manually." dwarn "Warning: specifying a non-makedumpfile core collector, you will have to recover the vmcore manually."
fi fi
@ -258,7 +268,7 @@ verify_core_collector() {
if is_ssh_dump_target || is_raw_dump_target; then if is_ssh_dump_target || is_raw_dump_target; then
if ! strstr "$_params" "-F"; then if ! strstr "$_params" "-F"; then
perror_exit "The specified dump target needs makedumpfile \"-F\" option." perror_exit 'The specified dump target needs makedumpfile "-F" option.'
fi fi
_params="$_params vmcore" _params="$_params vmcore"
else else
@ -271,7 +281,8 @@ verify_core_collector() {
fi fi
} }
add_mount() { add_mount()
{
local _mnt local _mnt
_mnt=$(to_mount "$@") || exit 1 _mnt=$(to_mount "$@") || exit 1
@ -304,7 +315,7 @@ for_each_block_target()
local dev majmin local dev majmin
for dev in $(get_kdump_targets); do for dev in $(get_kdump_targets); do
[[ -b "$dev" ]] || continue [[ -b $dev ]] || continue
majmin=$(get_maj_min "$dev") majmin=$(get_maj_min "$dev")
check_block_and_slaves "$1" "$majmin" && return 1 check_block_and_slaves "$1" "$majmin" && return 1
done done
@ -319,9 +330,9 @@ is_unresettable()
local path device resettable=1 local path device resettable=1
path="/sys/$(udevadm info --query=all --path="/sys/dev/block/$1" | awk '/^P:/ {print $2}' | sed -e 's/\(cciss[0-9]\+\/\).*/\1/g' -e 's/\/block\/.*$//')/resettable" path="/sys/$(udevadm info --query=all --path="/sys/dev/block/$1" | awk '/^P:/ {print $2}' | sed -e 's/\(cciss[0-9]\+\/\).*/\1/g' -e 's/\/block\/.*$//')/resettable"
if [[ -f "$path" ]]; then if [[ -f $path ]]; then
resettable="$(< "$path")" resettable="$(< "$path")"
[[ $resettable -eq 0 ]] && [[ "$OVERRIDE_RESETTABLE" -eq 0 ]] && { [[ $resettable -eq 0 ]] && [[ $OVERRIDE_RESETTABLE -eq 0 ]] && {
device=$(udevadm info --query=all --path="/sys/dev/block/$1" | awk -F= '/DEVNAME/{print $2}') device=$(udevadm info --query=all --path="/sys/dev/block/$1" | awk -F= '/DEVNAME/{print $2}')
derror "Error: Can not save vmcore because device $device is unresettable" derror "Error: Can not save vmcore because device $device is unresettable"
return 0 return 0
@ -369,13 +380,12 @@ fi
# firstly get right SSH_KEY_LOCATION # firstly get right SSH_KEY_LOCATION
keyfile=$(kdump_get_conf_val sshkey) keyfile=$(kdump_get_conf_val sshkey)
if [[ -f "$keyfile" ]]; then if [[ -f $keyfile ]]; then
# canonicalize the path # canonicalize the path
SSH_KEY_LOCATION=$(/usr/bin/readlink -m "$keyfile") SSH_KEY_LOCATION=$(/usr/bin/readlink -m "$keyfile")
fi fi
while read -r config_opt config_val; while read -r config_opt config_val; do
do
# remove inline comments after the end of a directive. # remove inline comments after the end of a directive.
case "$config_opt" in case "$config_opt" in
extra_modules) extra_modules)
@ -398,8 +408,7 @@ do
check_size raw "$config_val" check_size raw "$config_val"
;; ;;
ssh) ssh)
if strstr "$config_val" "@"; if strstr "$config_val" "@"; then
then
mkdir_save_path_ssh "$config_val" mkdir_save_path_ssh "$config_val"
check_size ssh "$config_val" check_size ssh "$config_val"
add_dracut_sshkey "$SSH_KEY_LOCATION" add_dracut_sshkey "$SSH_KEY_LOCATION"
@ -415,15 +424,14 @@ do
add_dracut_arg "$dracut_arg" add_dracut_arg "$dracut_arg"
done <<< "$(echo "$config_val" | xargs -n 1 echo)" done <<< "$(echo "$config_val" | xargs -n 1 echo)"
;; ;;
*) *) ;;
;;
esac esac
done <<< "$(kdump_read_conf)" done <<< "$(kdump_read_conf)"
handle_default_dump_target handle_default_dump_target
if [[ -n "$extra_modules" ]] if [[ -n $extra_modules ]]; then
then
add_dracut_arg "--add-drivers" "$extra_modules" add_dracut_arg "--add-drivers" "$extra_modules"
fi fi

View File

@ -44,15 +44,15 @@ fi
### Unpack the initramfs having dump capture capability ### Unpack the initramfs having dump capture capability
mkdir -p "$MKFADUMPRD_TMPDIR/fadumproot" mkdir -p "$MKFADUMPRD_TMPDIR/fadumproot"
if ! (pushd "$MKFADUMPRD_TMPDIR/fadumproot" > /dev/null && lsinitrd --unpack "$FADUMP_INITRD" && \ if ! (pushd "$MKFADUMPRD_TMPDIR/fadumproot" > /dev/null && lsinitrd --unpack "$FADUMP_INITRD" &&
popd > /dev/null); then popd > /dev/null); then
derror "mkfadumprd: failed to unpack '$MKFADUMPRD_TMPDIR'" derror "mkfadumprd: failed to unpack '$MKFADUMPRD_TMPDIR'"
exit 1 exit 1
fi fi
### Pack it into the normal boot initramfs with zz-fadumpinit module ### Pack it into the normal boot initramfs with zz-fadumpinit module
_dracut_isolate_args=(\ _dracut_isolate_args=(
--rebuild "$REBUILD_INITRD" --add zz-fadumpinit \ --rebuild "$REBUILD_INITRD" --add zz-fadumpinit
-i "$MKFADUMPRD_TMPDIR/fadumproot" /fadumproot -i "$MKFADUMPRD_TMPDIR/fadumproot" /fadumproot
-i "$MKFADUMPRD_TMPDIR/fadumproot/usr/lib/dracut/hostonly-kernel-modules.txt" -i "$MKFADUMPRD_TMPDIR/fadumproot/usr/lib/dracut/hostonly-kernel-modules.txt"
/usr/lib/dracut/fadump-kernel-modules.txt /usr/lib/dracut/fadump-kernel-modules.txt