kdumpctl: drop DUMP_TARGET variable
The variable is only used for ssh dump targets. Furthermore it is identical to the value stored in ${OPT[_target]}. Thus drop DUMP_TARGET and use ${OPT[_target]} instead. In order to be able to distinguish between the different target types introduce the internal ${OPT[_fstype]}. Signed-off-by: Philipp Rudo <prudo@redhat.com> Reviewed-by: Tao Liu <ltao@redhat.com> Reviewed-by: Coiby Xu <coxu@redhat.com>
This commit is contained in:
parent
a859abe365
commit
5118daf2ff
40
kdumpctl
40
kdumpctl
@ -10,7 +10,6 @@ MKDUMPRD="/sbin/mkdumprd -f"
|
|||||||
MKFADUMPRD="/sbin/mkfadumprd"
|
MKFADUMPRD="/sbin/mkfadumprd"
|
||||||
DRACUT_MODULES_FILE="/usr/lib/dracut/modules.txt"
|
DRACUT_MODULES_FILE="/usr/lib/dracut/modules.txt"
|
||||||
INITRD_CHECKSUM_LOCATION="/boot/.fadump_initrd_checksum"
|
INITRD_CHECKSUM_LOCATION="/boot/.fadump_initrd_checksum"
|
||||||
DUMP_TARGET=""
|
|
||||||
DEFAULT_INITRD=""
|
DEFAULT_INITRD=""
|
||||||
DEFAULT_INITRD_BAK=""
|
DEFAULT_INITRD_BAK=""
|
||||||
KDUMP_INITRD=""
|
KDUMP_INITRD=""
|
||||||
@ -196,7 +195,7 @@ _set_config()
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n ${OPT[$opt]} ]]; then
|
if [[ -n ${OPT[$opt]} ]]; then
|
||||||
if [[ $opt == _target ]]; then
|
if [[ $opt == _target ]] || [[ $opt == _fstype ]]; then
|
||||||
derror "More than one dump targets specified"
|
derror "More than one dump targets specified"
|
||||||
else
|
else
|
||||||
derror "Duplicated kdump config value of option $opt"
|
derror "Duplicated kdump config value of option $opt"
|
||||||
@ -216,6 +215,7 @@ parse_config()
|
|||||||
derror 'Multiple mount targets specified in one "dracut_args".'
|
derror 'Multiple mount targets specified in one "dracut_args".'
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
_set_config _fstype "$(get_dracut_args_fstype "$config_val")" || return 1
|
||||||
_set_config _target "$(get_dracut_args_target "$config_val")" || return 1
|
_set_config _target "$(get_dracut_args_target "$config_val")" || return 1
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
@ -223,15 +223,13 @@ parse_config()
|
|||||||
if [[ -d "/proc/device-tree/ibm,opal/dump" ]]; then
|
if [[ -d "/proc/device-tree/ibm,opal/dump" ]]; then
|
||||||
dwarn "WARNING: Won't capture opalcore when 'raw' dump target is used."
|
dwarn "WARNING: Won't capture opalcore when 'raw' dump target is used."
|
||||||
fi
|
fi
|
||||||
|
_set_config _fstype "$config_opt" || return 1
|
||||||
config_opt=_target
|
config_opt=_target
|
||||||
;;
|
;;
|
||||||
ext[234] | minix | btrfs | xfs | nfs )
|
ext[234] | minix | btrfs | xfs | nfs | ssh)
|
||||||
|
_set_config _fstype "$config_opt" || return 1
|
||||||
config_opt=_target
|
config_opt=_target
|
||||||
;;
|
;;
|
||||||
ssh)
|
|
||||||
config_opt=_target
|
|
||||||
DUMP_TARGET=$config_val
|
|
||||||
;;
|
|
||||||
sshkey)
|
sshkey)
|
||||||
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'"
|
||||||
@ -691,12 +689,12 @@ check_ssh_config()
|
|||||||
{
|
{
|
||||||
local target
|
local target
|
||||||
|
|
||||||
[[ -n $DUMP_TARGET ]] || return 0
|
[[ "${OPT[_fstype]}" == ssh ]] || return 0
|
||||||
|
|
||||||
[[ $DUMP_TARGET =~ .*@.* ]] || return 1
|
target=$(ssh -G "${OPT[_target]}" | sed -n -e "s/^hostname[[:space:]]\+\([^[:space:]]*\).*$/\1/p")
|
||||||
target=$(ssh -G "$DUMP_TARGET" | sed -n -e "s/^hostname[[:space:]]\+\([^[:space:]]*\).*$/\1/p")
|
[[ ${OPT[_target]} =~ .*@.* ]] || return 1
|
||||||
if [[ ${DUMP_TARGET#*@} != "$target" ]]; then
|
if [[ ${OPT[_target]#*@} != "$target" ]]; then
|
||||||
derror "Invalid ssh destination $DUMP_TARGET provided."
|
derror "Invalid ssh destination ${OPT[_target]} provided."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -715,25 +713,25 @@ check_and_wait_network_ready()
|
|||||||
local retval
|
local retval
|
||||||
local errmsg
|
local errmsg
|
||||||
|
|
||||||
[[ -n $DUMP_TARGET ]] || return 0
|
[[ "${OPT[_fstype]}" == ssh ]] || return 0
|
||||||
|
|
||||||
start_time=$(date +%s)
|
start_time=$(date +%s)
|
||||||
while true; do
|
while true; do
|
||||||
errmsg=$(ssh -i "${OPT[sshkey]}" -o BatchMode=yes "$DUMP_TARGET" mkdir -p "${OPT[path]}" 2>&1)
|
errmsg=$(ssh -i "${OPT[sshkey]}" -o BatchMode=yes "${OPT[_target]}" mkdir -p "${OPT[path]}" 2>&1)
|
||||||
retval=$?
|
retval=$?
|
||||||
|
|
||||||
# ssh exits with the exit status of the remote command or with 255 if an error occurred
|
# ssh exits with the exit status of the remote command or with 255 if an error occurred
|
||||||
if [[ $retval -eq 0 ]]; then
|
if [[ $retval -eq 0 ]]; then
|
||||||
return 0
|
return 0
|
||||||
elif [[ $retval -ne 255 ]]; then
|
elif [[ $retval -ne 255 ]]; then
|
||||||
derror "Could not create $DUMP_TARGET:${OPT[path]}, you should check the privilege on server side"
|
derror "Could not create ${OPT[_target]}:${OPT[path]}, you should check the privilege on server side"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# if server removes the authorized_keys or, no /root/.ssh/kdump_id_rsa
|
# if server removes the authorized_keys or, no /root/.ssh/kdump_id_rsa
|
||||||
ddebug "$errmsg"
|
ddebug "$errmsg"
|
||||||
if echo "$errmsg" | grep -q "Permission denied\|No such file or directory\|Host key verification failed"; then
|
if echo "$errmsg" | grep -q "Permission denied\|No such file or directory\|Host key verification failed"; then
|
||||||
derror "Could not create $DUMP_TARGET:${OPT[path]}, you probably need to run \"kdumpctl propagate\""
|
derror "Could not create ${OPT[_target]}:${OPT[path]}, you probably need to run \"kdumpctl propagate\""
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -751,7 +749,7 @@ check_and_wait_network_ready()
|
|||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
|
|
||||||
dinfo "Could not create $DUMP_TARGET:${OPT[path]}, ipaddr is not ready yet. You should check network connection"
|
dinfo "Could not create ${OPT[_target]}:${OPT[path]}, ipaddr is not ready yet. You should check network connection"
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -761,7 +759,7 @@ propagate_ssh_key()
|
|||||||
|
|
||||||
parse_config || return 1
|
parse_config || return 1
|
||||||
|
|
||||||
if [[ -z $DUMP_TARGET ]] ; then
|
if [[ ${OPT[_fstype]} != ssh ]] ; then
|
||||||
derror "No ssh destination defined in $KDUMP_CONFIG_FILE."
|
derror "No ssh destination defined in $KDUMP_CONFIG_FILE."
|
||||||
derror "Please verify that $KDUMP_CONFIG_FILE contains 'ssh <user>@<host>' and that it is properly formatted."
|
derror "Please verify that $KDUMP_CONFIG_FILE contains 'ssh <user>@<host>' and that it is properly formatted."
|
||||||
exit 1
|
exit 1
|
||||||
@ -778,9 +776,9 @@ propagate_ssh_key()
|
|||||||
dinfo "done."
|
dinfo "done."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
SSH_USER=${DUMP_TARGET%@*}
|
SSH_USER=${OPT[_target]%@*}
|
||||||
SSH_SERVER=${DUMP_TARGET#*@}
|
SSH_SERVER=${OPT[_target]#*@}
|
||||||
if ssh-copy-id -i "$KEYFILE" "$DUMP_TARGET"; then
|
if ssh-copy-id -i "$KEYFILE" "${OPT[_target]}"; then
|
||||||
dinfo "$KEYFILE has been added to ~$SSH_USER/.ssh/authorized_keys on $SSH_SERVER"
|
dinfo "$KEYFILE has been added to ~$SSH_USER/.ssh/authorized_keys on $SSH_SERVER"
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user