This commit makes kdump's module-setup.sh modify known_hosts
file installed to dracut, adding 'kdump-' interface prefix to
items interface name like 'eth*'. This ensures that the ssh
target is known while dumping.
Signed-off-by: Ziyue Yang <ziyang(a)redhat.com>
---
dracut-module-setup.sh | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index ae13337..2fe7c94 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -707,12 +707,34 @@ kdump_install_random_seed() {
bs=$poolsize count=1 2> /dev/null
}
+# Install kdump-specialized known_hosts, which is needed
+# to provide correct network interface name while ssh dumping
+kdump_install_ssh_known_hosts() {
+ local _origin_known_hosts=/root/.ssh/known_hosts
+ local _tmp_known_hosts=$initdir/tmp/kdump_known_hosts
+ while read -r known_host;
+ do
+ echo $known_host
+ if [[ $known_host == *":"* ]]; then
+ local _host_prefix=${known_host%\%*}
+ local _host_postfix=${known_host##*\%}
+ if [[ $_host_postfix == "eth"* ]]; then
+ echo "$_host_prefix%kdump-$_host_postfix"
+ fi
+ fi
+ done < $_origin_known_hosts > $_tmp_known_hosts
+ # replace origin known_hosts
+ cp $_tmp_known_hosts $initdir/$_origin_known_hosts
+ rm -f $_tmp_known_hosts
+}
+
install() {
kdump_install_conf
remove_sysctl_conf
if is_ssh_dump_target; then
kdump_install_random_seed
+ kdump_install_ssh_known_hosts
fi
dracut_install -o /etc/adjtime /etc/localtime
inst "$moddir/monitor_dd_progress"
"/kdumpscripts/monitor_dd_progress"
--
2.9.3