2011-08-01 09:19:24 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2012-01-27 14:59:43 +00:00
|
|
|
. $dracutfunctions
|
|
|
|
|
2011-08-01 09:19:24 +00:00
|
|
|
check() {
|
|
|
|
[[ $debug ]] && set -x
|
|
|
|
#kdumpctl sets this explicitly
|
|
|
|
if [ -z "$IN_KDUMP" ] || [ ! -f /etc/kdump.conf ]
|
|
|
|
then
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2012-01-27 14:59:43 +00:00
|
|
|
depends() {
|
|
|
|
echo "base shutdown"
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2011-08-02 06:00:50 +00:00
|
|
|
to_udev_name() {
|
2011-08-01 15:40:35 +00:00
|
|
|
local dev="$1"
|
|
|
|
|
|
|
|
case "$dev" in
|
|
|
|
UUID=*)
|
|
|
|
dev=`blkid -U "${dev#UUID=}"`
|
|
|
|
;;
|
|
|
|
LABEL=*)
|
|
|
|
dev=`blkid -L "${dev#LABEL=}"`
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
echo ${dev#/dev/}
|
|
|
|
}
|
|
|
|
|
2012-01-27 14:59:43 +00:00
|
|
|
is_bridge() {
|
|
|
|
[ -d /sys/class/net/"$1"/bridge ]
|
|
|
|
}
|
|
|
|
|
|
|
|
is_bond() {
|
|
|
|
[ -d /sys/class/net/"$1"/bonding ]
|
2011-08-01 09:19:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
install() {
|
2012-01-27 14:59:43 +00:00
|
|
|
local _server
|
|
|
|
local _netdev
|
|
|
|
|
2012-01-25 08:58:35 +00:00
|
|
|
sed -ne '/^#/!p' /etc/kdump.conf > /tmp/$$-kdump.conf
|
2011-08-01 16:33:14 +00:00
|
|
|
while read config_opt config_val;
|
|
|
|
do
|
|
|
|
case "$config_opt" in
|
|
|
|
ext[234]|xfs|btrfs|minix|raw)
|
2012-01-27 14:59:43 +00:00
|
|
|
sed -i -e "s#$config_val#/dev/$(to_udev_name $config_val)#" /tmp/$$-kdump.conf
|
|
|
|
;;
|
|
|
|
net)
|
|
|
|
if strstr "$config_val" "@"; then
|
2012-02-22 03:16:09 +00:00
|
|
|
_server=`echo $config_val | sed 's/.*@//' | cut -d':' -f1`
|
2012-01-27 14:59:43 +00:00
|
|
|
else
|
|
|
|
_server=$(echo $config_val | sed -e 's#\(.*\):.*#\1#')
|
|
|
|
fi
|
|
|
|
|
2012-03-29 06:56:06 +00:00
|
|
|
_need_dns=`echo $_server|grep "[a-zA-Z]"`
|
2012-04-11 09:59:25 +00:00
|
|
|
[ -n "$_need_dns" ] && _server=`getent hosts $_server|cut -d' ' -f1`
|
2012-03-29 06:56:06 +00:00
|
|
|
|
2012-01-27 14:59:43 +00:00
|
|
|
_netdev=`/sbin/ip route get to $_server 2>&1`
|
|
|
|
[ $? != 0 ] && echo "Bad kdump location: $config_val" && exit 1
|
|
|
|
#the field in the ip output changes if we go to another subnet
|
|
|
|
if [ -n "`echo $_netdev | grep via`" ]
|
|
|
|
then
|
|
|
|
# we are going to a different subnet
|
|
|
|
_netdev=`echo $_netdev|awk '{print $5;}'|head -n 1`
|
|
|
|
else
|
|
|
|
# we are on the same subnet
|
|
|
|
_netdev=`echo $_netdev|awk '{print $3}'|head -n 1`
|
|
|
|
fi
|
2012-04-18 03:12:17 +00:00
|
|
|
_netmac=`ip addr show $_netdev 2>/dev/null|awk '/ether/{ print $2 }'`
|
|
|
|
echo " ip=$_netdev:dhcp ifname=$_netdev:$_netmac rd.neednet=1" > ${initdir}/etc/cmdline.d/40ip.conf
|
2012-01-27 14:59:43 +00:00
|
|
|
if is_bridge "$_netdev"; then
|
|
|
|
echo " bridge=$_netdev:$(cd /sys/class/net/$_netdev/brif/; echo *)" > ${initdir}/etc/cmdline.d/41bridge.conf
|
|
|
|
elif is_bond "$_netdev"; then
|
|
|
|
echo " bond=$_netdev:\"$(cat /sys/class/net/$_netdev/bonding/slaves)\"" > ${initdir}/etc/cmdline.d/42bond.conf
|
|
|
|
#TODO
|
|
|
|
#echo "bondoptions=\"$bondoptions\"" >> /tmp/$$-bond
|
|
|
|
else
|
|
|
|
:
|
|
|
|
fi
|
2011-08-01 16:33:14 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done < /etc/kdump.conf
|
|
|
|
|
2011-08-01 09:19:24 +00:00
|
|
|
inst "/bin/date" "/bin/date"
|
|
|
|
inst "/bin/sync" "/bin/sync"
|
2012-02-22 03:16:09 +00:00
|
|
|
inst "/bin/cut" "/bin/cut"
|
2011-08-01 09:19:24 +00:00
|
|
|
inst "/sbin/makedumpfile" "/sbin/makedumpfile"
|
2011-08-02 08:42:21 +00:00
|
|
|
inst "/tmp/$$-kdump.conf" "/etc/kdump.conf"
|
2012-02-22 03:16:09 +00:00
|
|
|
inst_hook pre-pivot 0000 "$moddir/kdump.sh"
|
2011-08-01 09:19:24 +00:00
|
|
|
}
|