diff --git a/mkdumprd b/mkdumprd index 225f19c..d596c4d 100644 --- a/mkdumprd +++ b/mkdumprd @@ -10,14 +10,22 @@ export IN_KDUMP=1 conf_file="/etc/kdump.conf" extra_modules="" -dracut_args="-m kdumpbase --add dash --add fstab-sys -c /dev/null" +dracut_args=("-m" "kdumpbase" "--add" "dash" "--add" "fstab-sys" "-c" "/dev/null") add_dracut_arg() { - dracut_args="$dracut_args $*" + while [ $# -gt 0 ]; + do + dracut_args+=("$1") + shift + done } add_dracut_module() { - add_dracut_arg "--add $1" + add_dracut_arg "--add" "$1" +} + +add_dracut_mount() { + add_dracut_arg "--mount" "$1" } while [ $# -gt 0 ]; do @@ -43,7 +51,7 @@ done # Generic substring function. If $2 is in $1, return 0. strstr() { [[ $1 =~ $2 ]]; } -to_udev_name() { +to_dev_name() { local dev="$1" case "$dev" in @@ -54,7 +62,12 @@ to_udev_name() { dev=`blkid -L "${dev#LABEL=}"` ;; esac - echo ${dev#/dev/} + echo $dev +} + +to_mount() { + local _dev=$(to_dev_name $1) + echo "$(grep "$_dev" /proc/mounts | cut -d' ' -f1-4)" } # $1 remote target @@ -70,7 +83,7 @@ if [ -n "$conf_file" ]; then extra_modules="$extra_modules $config_val" ;; ext[234]|xfs|btrfs|minix) - add_dracut_arg "--mount $(to_udev_name $config_val)" + add_dracut_mount "$(to_mount $config_val)" ;; raw) #TODO @@ -82,7 +95,7 @@ if [ -n "$conf_file" ]; then add_dracut_module "scp" else add_dracut_module "nfs" - add_dracut_arg "--mount $config_val" + add_dracut_mount "$(to_mount $config_val)" fi ;; core_collector) @@ -106,6 +119,6 @@ then add_dracut_arg "--add-drivers $extra_modules" fi -dracut $dracut_args -M "$@" +dracut "${dracut_args[@]}" -M "$@" exit $?