126 lines
2.3 KiB
Bash
126 lines
2.3 KiB
Bash
#!/bin/bash --norc
|
|
# New mkdumprd
|
|
#
|
|
# Copyright 2011 Red Hat, Inc.
|
|
#
|
|
# Written by Cong Wang <amwang@redhat.com>
|
|
#
|
|
|
|
export IN_KDUMP=1
|
|
|
|
conf_file="/etc/kdump.conf"
|
|
extra_modules=""
|
|
dracut_args=("-m" "kdumpbase" "--add" "dash" "--add" "fstab-sys" "-c" "/dev/null" "-I" "/sbin/makedumpfile")
|
|
|
|
add_dracut_arg() {
|
|
while [ $# -gt 0 ];
|
|
do
|
|
dracut_args+=("$1")
|
|
shift
|
|
done
|
|
}
|
|
|
|
add_dracut_module() {
|
|
add_dracut_arg "--add" "$1"
|
|
}
|
|
|
|
add_dracut_mount() {
|
|
add_dracut_arg "--mount" "$1"
|
|
}
|
|
|
|
while [ $# -gt 0 ]; do
|
|
case $1 in
|
|
-d)
|
|
shift
|
|
;;
|
|
--noconf)
|
|
conf_file=""
|
|
shift
|
|
;;
|
|
--debug)
|
|
add_dracut_arg "-v"
|
|
set -x
|
|
shift
|
|
;;
|
|
*)
|
|
break
|
|
;;
|
|
esac
|
|
done
|
|
|
|
# Generic substring function. If $2 is in $1, return 0.
|
|
strstr() { [[ $1 =~ $2 ]]; }
|
|
|
|
to_dev_name() {
|
|
local dev="$1"
|
|
|
|
case "$dev" in
|
|
UUID=*)
|
|
dev=`blkid -U "${dev#UUID=}"`
|
|
;;
|
|
LABEL=*)
|
|
dev=`blkid -L "${dev#LABEL=}"`
|
|
;;
|
|
esac
|
|
echo $dev
|
|
}
|
|
|
|
to_mount() {
|
|
local _dev=$(to_dev_name $1)
|
|
echo "$(grep "$_dev" /proc/mounts | cut -d' ' -f1-4)"
|
|
}
|
|
|
|
# $1 remote target
|
|
check_remote() {
|
|
return
|
|
}
|
|
|
|
if [ -n "$conf_file" ]; then
|
|
while read config_opt config_val;
|
|
do
|
|
case "$config_opt" in
|
|
extra_modules)
|
|
extra_modules="$extra_modules $config_val"
|
|
;;
|
|
ext[234]|xfs|btrfs|minix)
|
|
add_dracut_mount "$(to_mount $config_val)"
|
|
;;
|
|
raw)
|
|
#TODO
|
|
;;
|
|
net)
|
|
check_remote "$config_val"
|
|
if strstr "$config_val" "@";
|
|
then
|
|
add_dracut_module "ssh-client"
|
|
else
|
|
add_dracut_module "nfs"
|
|
add_dracut_mount "$(to_mount $config_val)"
|
|
fi
|
|
;;
|
|
core_collector)
|
|
add_dracut_arg "-I" "${config_val% *}"
|
|
;;
|
|
extra_bins)
|
|
add_dracut_arg "-I" "$config_val"
|
|
;;
|
|
*)
|
|
if [ -n $(echo $config_opt | grep "^#.*$") ]
|
|
then
|
|
continue
|
|
fi
|
|
;;
|
|
esac
|
|
done < $conf_file
|
|
fi
|
|
|
|
if [ -n "$extra_modules" ]
|
|
then
|
|
add_dracut_arg "--add-drivers" "$extra_modules"
|
|
fi
|
|
|
|
dracut "${dracut_args[@]}" -M "$@"
|
|
sync
|
|
exit $?
|
|
|