From b47c0915d21d56bd6f13a4543656c1c63985e736 Mon Sep 17 00:00:00 2001 From: Dave Young Date: Mon, 23 Jul 2012 15:31:28 +0800 Subject: [PATCH] refactor net option Currently net options means either nfs or ssh dump. Better to split these two into standalone options. That's more clear to user. after the split, ssh dump need user specify "ssh user@host" nfs dump need user specify "nfs host:nfsshare" Signed-off-by: Dave Young Acked-by: Vivek Goyal --- dracut-kdump.sh | 12 ++++-------- dracut-module-setup.sh | 2 +- kdump.conf | 8 ++++---- kdump.conf.5 | 4 ++-- kdumpctl | 4 ++-- kexec-kdump-howto.txt | 2 +- mkdumprd | 22 ++++++++++++---------- 7 files changed, 26 insertions(+), 28 deletions(-) diff --git a/dracut-kdump.sh b/dracut-kdump.sh index 144cc88..fed3cf3 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -144,7 +144,7 @@ dump_ssh() is_ssh_dump_target() { - grep -q "^net.*@" $conf_file + grep -q "^ssh.*@" $conf_file } is_raw_dump_target() @@ -203,19 +203,15 @@ read_kdump_conf() while read config_opt config_val; do case "$config_opt" in - ext[234]|xfs|btrfs|minix) + ext[234]|xfs|btrfs|minix|nfs) add_dump_code "dump_fs $config_val" ;; raw) add_dump_code "dump_raw $config_val" ;; - net) + ssh) wait_for_net_ok - if [[ "$config_val" =~ "@" ]]; then - add_dump_code "dump_ssh $SSH_KEY_LOCATION $config_val" - else - add_dump_code "dump_fs $config_val" - fi + add_dump_code "dump_ssh $SSH_KEY_LOCATION $config_val" ;; esac done < $conf_file diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 8ef9c36..9fe9f71 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -195,7 +195,7 @@ kdump_install_conf() { ext[234]|xfs|btrfs|minix|raw) sed -i -e "s#$config_val#/dev/$(kdump_to_udev_name $config_val)#" /tmp/$$-kdump.conf ;; - net) + ssh|nfs) kdump_install_net "$config_val" ;; kdump_pre|kdump_post|extra_bins) diff --git a/kdump.conf b/kdump.conf index 245a8cb..da47d00 100644 --- a/kdump.conf +++ b/kdump.conf @@ -13,10 +13,10 @@ # Basics commands supported are: # raw - Will dd /proc/vmcore into . # -# net - Will mount fs and copy /proc/vmcore to +# nfs - Will mount fs and copy /proc/vmcore to # /var/crash/%HOST-%DATE/, supports DNS. # -# net - Will scp /proc/vmcore to +# ssh - Will scp /proc/vmcore to # :/var/crash/%HOST-%DATE/, supports DNS # NOTE: make sure user has necessary write # permissions on server @@ -108,8 +108,8 @@ #ext4 /dev/sda3 #ext4 LABEL=/boot #ext4 UUID=03138356-5e61-4ab3-b58e-27507ac41937 -#net my.server.com:/export/tmp -#net user@my.server.com +#nfs my.server.com:/export/tmp +#ssh user@my.server.com #sshkey /root/.ssh/kdump_id_rsa #blacklist cfg80211 path /var/crash diff --git a/kdump.conf.5 b/kdump.conf.5 index 99075a6..2dfd041 100644 --- a/kdump.conf.5 +++ b/kdump.conf.5 @@ -28,14 +28,14 @@ understand how this configuration file affects the behavior of kdump. Will dd /proc/vmcore into . .RE -.B net +.B nfs .RS Will mount fs and copy /proc/vmcore to /var/crash/%HOST-%DATE/, supports DNS. Note that a fqdn should be used as the server name in the mount point .RE -.B net +.B ssh .RS Will scp /proc/vmcore to :/var/crash/%HOST-%DATE/, supports DNS. NOTE: make sure user has necessary write permissions on diff --git a/kdumpctl b/kdumpctl index ac162b5..5781da9 100755 --- a/kdumpctl +++ b/kdumpctl @@ -224,7 +224,7 @@ function check_ssh_config() path) SAVE_PATH=$config_val ;; - net) + ssh) DUMP_TARGET=$config_val ;; *) @@ -355,7 +355,7 @@ function save_raw() function start() { local nr - nr=$(awk 'BEGIN{cnt=0} /^raw|^net|^ext[234]|^xfs|^btrfs|^minix/{cnt++} END{print cnt}' $KDUMP_CONFIG_FILE) + nr=$(awk 'BEGIN{cnt=0} /^raw|^ssh|^nfs|^ext[234]|^xfs|^btrfs|^minix/{cnt++} END{print cnt}' $KDUMP_CONFIG_FILE) [ $nr -gt 1 ] && { echo -n "Error: More than one dump targets specified"; echo return 1 diff --git a/kexec-kdump-howto.txt b/kexec-kdump-howto.txt index 53d3e6f..bedb38e 100644 --- a/kexec-kdump-howto.txt +++ b/kexec-kdump-howto.txt @@ -375,7 +375,7 @@ Remote system via ssh/scp Dumping over ssh/scp requires setting up passwordless ssh keys for every machine you wish to have dump via this method. First up, configure kdump.conf -for ssh/scp dumping, adding a config line of 'net user@server', where 'user' +for ssh/scp dumping, adding a config line of 'ssh user@server', where 'user' can be any user on the target system you choose, and 'server' is the host name or IP address of the target system. Using a dedicated, restricted user account on the target system is recommended, as there will be keyless ssh diff --git a/mkdumprd b/mkdumprd index 2d9ba46..5948e50 100644 --- a/mkdumprd +++ b/mkdumprd @@ -130,7 +130,7 @@ check_size() { is_ssh_dump_target() { - grep -q "^net.*@" $conf_file + grep -q "^ssh.*@" $conf_file } is_raw_dump_target() @@ -183,7 +183,10 @@ do extra_modules) extra_modules="$extra_modules $config_val" ;; - ext[234]|xfs|btrfs|minix) + ext[234]|xfs|btrfs|minix|nfs) + if [ "$config_opt" = "nfs" ]; then + add_dracut_module "nfs" + fi add_mount "$config_val" if [ $? -ne 0 ]; then echo "Dump target $config_val is probably not mounted." @@ -199,22 +202,21 @@ do } check_size raw $config_val ;; - net) + ssh) if strstr "$config_val" "@"; then check_size ssh $config_val add_dracut_module "ssh-client" add_dracut_sshkey "$SSH_KEY_LOCATION" else - add_dracut_module "nfs" - add_mount "$config_val" - if [ $? -ne 0 ]; then - echo "Dump target $config_val is probably not mounted." - exit 1 - fi - check_size fs $config_val + echo "Bad ssh dump target $config_val" + exit 1 fi ;; + net) + echo "net option is not supported anymore, please use nfs|ssh instead." + exit 1 + ;; core_collector) verify_core_collector "$config_val" ;;