|
|
ab224c |
#!/bin/bash
|
|
|
ab224c |
|
|
|
ab224c |
. $dracutfunctions
|
|
|
ab224c |
. /lib/kdump/kdump-lib.sh
|
|
|
ab224c |
|
|
|
ab224c |
check() {
|
|
|
ab224c |
[[ $debug ]] && set -x
|
|
|
ab224c |
#kdumpctl sets this explicitly
|
|
|
ab224c |
if [ -z "$IN_KDUMP" ] || [ ! -f /etc/kdump.conf ]
|
|
|
ab224c |
then
|
|
|
ab224c |
return 1
|
|
|
ab224c |
fi
|
|
|
ab224c |
return 0
|
|
|
ab224c |
}
|
|
|
ab224c |
|
|
|
ab224c |
depends() {
|
|
|
ab224c |
local _dep="base shutdown"
|
|
|
ab224c |
|
|
|
ab224c |
if [ -d /sys/module/drm/drivers ]; then
|
|
|
ab224c |
_dep="$_dep drm"
|
|
|
ab224c |
fi
|
|
|
ab224c |
|
|
|
765b01 |
if is_fence_kdump; then
|
|
|
765b01 |
_dep="$_dep network"
|
|
|
765b01 |
fi
|
|
|
765b01 |
|
|
|
ab224c |
echo $_dep
|
|
|
ab224c |
return 0
|
|
|
ab224c |
}
|
|
|
ab224c |
|
|
|
ab224c |
kdump_to_udev_name() {
|
|
|
ab224c |
local dev="${1//\"/}"
|
|
|
ab224c |
|
|
|
ab224c |
case "$dev" in
|
|
|
ab224c |
UUID=*)
|
|
|
ab224c |
dev=`blkid -U "${dev#UUID=}"`
|
|
|
ab224c |
;;
|
|
|
ab224c |
LABEL=*)
|
|
|
ab224c |
dev=`blkid -L "${dev#LABEL=}"`
|
|
|
ab224c |
;;
|
|
|
ab224c |
esac
|
|
|
ab224c |
echo $(get_persistent_dev "$dev")
|
|
|
ab224c |
}
|
|
|
ab224c |
|
|
|
ab224c |
kdump_is_bridge() {
|
|
|
ab224c |
[ -d /sys/class/net/"$1"/bridge ]
|
|
|
ab224c |
}
|
|
|
ab224c |
|
|
|
ab224c |
kdump_is_bond() {
|
|
|
ab224c |
[ -d /sys/class/net/"$1"/bonding ]
|
|
|
ab224c |
}
|
|
|
ab224c |
|
|
|
ab224c |
kdump_is_team() {
|
|
|
ab224c |
[ -f /usr/bin/teamnl ] && teamnl $1 ports &> /dev/null
|
|
|
ab224c |
}
|
|
|
ab224c |
|
|
|
ab224c |
kdump_is_vlan() {
|
|
|
ab224c |
[ -f /proc/net/vlan/"$1" ]
|
|
|
ab224c |
}
|
|
|
ab224c |
|
|
|
ab224c |
# $1: netdev name
|
|
|
ab224c |
kdump_setup_dns() {
|
|
|
ab224c |
_dnsfile=${initdir}/etc/cmdline.d/42dns.conf
|
|
|
ab224c |
. /etc/sysconfig/network-scripts/ifcfg-$1
|
|
|
ab224c |
[ -n "$DNS1" ] && echo "nameserver=$DNS1" > "$_dnsfile"
|
|
|
ab224c |
[ -n "$DNS2" ] && echo "nameserver=$DNS2" >> "$_dnsfile"
|
|
|
ab224c |
}
|
|
|
ab224c |
|
|
|
ab224c |
#$1: netdev name
|
|
|
3dae34 |
#$2: srcaddr
|
|
|
ab224c |
#if it use static ip echo it, or echo null
|
|
|
ab224c |
kdump_static_ip() {
|
|
|
3dae34 |
local _netmask _gateway
|
|
|
3dae34 |
local _netdev="$1" _srcaddr="$2"
|
|
|
3dae34 |
local _ipaddr=$(ip addr show dev $_netdev permanent | \
|
|
|
3dae34 |
awk "/ $_srcaddr\/.* $_netdev\$/{print \$2}")
|
|
|
3dae34 |
if [ -n "$_ipaddr" ]; then
|
|
|
3dae34 |
_netmask=$(ipcalc -m $_ipaddr | cut -d'=' -f2)
|
|
|
3dae34 |
_gateway=$(ip route list dev $_netdev | awk '/^default /{print $3}')
|
|
|
3dae34 |
echo -n "${_srcaddr}::${_gateway}:${_netmask}::"
|
|
|
ab224c |
fi
|
|
|
ab224c |
}
|
|
|
ab224c |
|
|
|
ab224c |
kdump_get_mac_addr() {
|
|
|
ab224c |
cat /sys/class/net/$1/address
|
|
|
ab224c |
}
|
|
|
ab224c |
|
|
|
ab224c |
#Bonding or team master modifies the mac address
|
|
|
ab224c |
#of its slaves, we should use perm address
|
|
|
ab224c |
kdump_get_perm_addr() {
|
|
|
ab224c |
local addr=$(ethtool -P $1 | sed -e 's/Permanent address: //')
|
|
|
ab224c |
if [ -z "$addr" ] || [ "$addr" = "00:00:00:00:00:00" ]
|
|
|
ab224c |
then
|
|
|
ab224c |
derror "Can't get the permanent address of $1"
|
|
|
ab224c |
else
|
|
|
ab224c |
echo "$addr"
|
|
|
ab224c |
fi
|
|
|
ab224c |
}
|
|
|
ab224c |
|
|
|
a465a3 |
# Prefix kernel assigned names with "kdump-". EX: eth0 -> kdump-eth0
|
|
|
a465a3 |
# Because kernel assigned names are not persistent between 1st and 2nd
|
|
|
a465a3 |
# kernel. We could probably end up with eth0 being eth1, eth0 being
|
|
|
a465a3 |
# eth1, and naming conflict happens.
|
|
|
a465a3 |
kdump_setup_ifname() {
|
|
|
a465a3 |
local _ifname
|
|
|
a465a3 |
|
|
|
a465a3 |
if [[ $1 =~ eth* ]]; then
|
|
|
a465a3 |
_ifname="kdump-$1"
|
|
|
a465a3 |
else
|
|
|
a465a3 |
_ifname="$1"
|
|
|
a465a3 |
fi
|
|
|
a465a3 |
|
|
|
a465a3 |
echo "$_ifname"
|
|
|
a465a3 |
}
|
|
|
a465a3 |
|
|
|
ab224c |
kdump_setup_bridge() {
|
|
|
ab224c |
local _netdev=$1
|
|
|
a465a3 |
local _brif _dev _mac _kdumpdev
|
|
|
ab224c |
for _dev in `ls /sys/class/net/$_netdev/brif/`; do
|
|
|
a465a3 |
_kdumpdev=$_dev
|
|
|
ab224c |
if kdump_is_bond "$_dev"; then
|
|
|
ab224c |
kdump_setup_bond "$_dev"
|
|
|
ab224c |
elif kdump_is_team "$_dev"; then
|
|
|
ab224c |
kdump_setup_team "$_dev"
|
|
|
ab224c |
elif kdump_is_vlan "$_dev"; then
|
|
|
ab224c |
kdump_setup_vlan "$_dev"
|
|
|
ab224c |
else
|
|
|
a465a3 |
_mac=$(kdump_get_mac_addr $_dev)
|
|
|
a465a3 |
_kdumpdev=$(kdump_setup_ifname $_dev)
|
|
|
a465a3 |
echo -n " ifname=$_kdumpdev:$_mac" >> ${initdir}/etc/cmdline.d/41bridge.conf
|
|
|
ab224c |
fi
|
|
|
a465a3 |
_brif+="$_kdumpdev,"
|
|
|
ab224c |
done
|
|
|
ab224c |
echo " bridge=$_netdev:$(echo $_brif | sed -e 's/,$//')" >> ${initdir}/etc/cmdline.d/41bridge.conf
|
|
|
ab224c |
}
|
|
|
ab224c |
|
|
|
ab224c |
kdump_setup_bond() {
|
|
|
ab224c |
local _netdev=$1
|
|
|
a465a3 |
local _dev _mac _slaves _kdumpdev
|
|
|
ab224c |
for _dev in `cat /sys/class/net/$_netdev/bonding/slaves`; do
|
|
|
a465a3 |
_mac=$(kdump_get_perm_addr $_dev)
|
|
|
a465a3 |
_kdumpdev=$(kdump_setup_ifname $_dev)
|
|
|
a465a3 |
echo -n " ifname=$_kdumpdev:$_mac" >> ${initdir}/etc/cmdline.d/42bond.conf
|
|
|
a465a3 |
_slaves+="$_kdumpdev,"
|
|
|
ab224c |
done
|
|
|
a465a3 |
echo -n " bond=$_netdev:$(echo $_slaves | sed 's/,$//')" >> ${initdir}/etc/cmdline.d/42bond.conf
|
|
|
ab224c |
# Get bond options specified in ifcfg
|
|
|
ab224c |
. /etc/sysconfig/network-scripts/ifcfg-$_netdev
|
|
|
ab224c |
bondoptions="$(echo :$BONDING_OPTS | sed 's/\s\+/,/')"
|
|
|
ab224c |
echo "$bondoptions" >> ${initdir}/etc/cmdline.d/42bond.conf
|
|
|
ab224c |
}
|
|
|
ab224c |
|
|
|
ab224c |
kdump_setup_team() {
|
|
|
ab224c |
local _netdev=$1
|
|
|
a465a3 |
local _dev _mac _slaves _kdumpdev
|
|
|
ab224c |
for _dev in `teamnl $_netdev ports | awk -F':' '{print $2}'`; do
|
|
|
a465a3 |
_mac=$(kdump_get_perm_addr $_dev)
|
|
|
a465a3 |
_kdumpdev=$(kdump_setup_ifname $_dev)
|
|
|
a465a3 |
echo -n " ifname=$_kdumpdev:$_mac" >> ${initdir}/etc/cmdline.d/44team.conf
|
|
|
a465a3 |
_slaves+="$_kdumpdev,"
|
|
|
ab224c |
done
|
|
|
a465a3 |
echo " team=$_netdev:$(echo $_slaves | sed -e 's/,$//')" >> ${initdir}/etc/cmdline.d/44team.conf
|
|
|
ab224c |
#Buggy version teamdctl outputs to stderr!
|
|
|
ab224c |
#Try to use the latest version of teamd.
|
|
|
ab224c |
teamdctl "$_netdev" config dump > /tmp/$$-$_netdev.conf
|
|
|
ab224c |
if [ $? -ne 0 ]
|
|
|
ab224c |
then
|
|
|
ab224c |
derror "teamdctl failed."
|
|
|
ab224c |
exit 1
|
|
|
ab224c |
fi
|
|
|
ab224c |
inst_dir /etc/teamd
|
|
|
ab224c |
inst_simple /tmp/$$-$_netdev.conf "/etc/teamd/$_netdev.conf"
|
|
|
ab224c |
rm -f /tmp/$$-$_netdev.conf
|
|
|
ab224c |
}
|
|
|
ab224c |
|
|
|
ab224c |
kdump_setup_vlan() {
|
|
|
ab224c |
local _netdev=$1
|
|
|
ab224c |
local _phydev="$(awk '/^Device:/{print $2}' /proc/net/vlan/"$_netdev")"
|
|
|
ab224c |
local _netmac="$(kdump_get_mac_addr $_phydev)"
|
|
|
a465a3 |
local _kdumpdev
|
|
|
ab224c |
|
|
|
ab224c |
#Just support vlan over bond, it is not easy
|
|
|
ab224c |
#to support all other complex setup
|
|
|
ab224c |
if kdump_is_bridge "$_phydev"; then
|
|
|
ab224c |
derror "Vlan over bridge is not supported!"
|
|
|
ab224c |
exit 1
|
|
|
ab224c |
elif kdump_is_team "$_phydev"; then
|
|
|
ab224c |
derror "Vlan over team is not supported!"
|
|
|
ab224c |
exit 1
|
|
|
ab224c |
elif kdump_is_bond "$_phydev"; then
|
|
|
ab224c |
kdump_setup_bond "$_phydev"
|
|
|
a465a3 |
echo " vlan=$_netdev:$_phydev" > ${initdir}/etc/cmdline.d/43vlan.conf
|
|
|
ab224c |
else
|
|
|
a465a3 |
_kdumpdev="$(kdump_setup_ifname $_phydev)"
|
|
|
a465a3 |
echo " vlan=$_netdev:$_kdumpdev ifname=$_kdumpdev:$_netmac" > ${initdir}/etc/cmdline.d/43vlan.conf
|
|
|
ab224c |
fi
|
|
|
ab224c |
}
|
|
|
ab224c |
|
|
|
ab224c |
# setup s390 znet cmdline
|
|
|
ab224c |
# $1: netdev name
|
|
|
ab224c |
kdump_setup_znet() {
|
|
|
ab224c |
local _options=""
|
|
|
ab224c |
. /etc/sysconfig/network-scripts/ifcfg-$1
|
|
|
ab224c |
for i in $OPTIONS; do
|
|
|
ab224c |
_options=${_options},$i
|
|
|
ab224c |
done
|
|
|
ab224c |
echo rd.znet=${NETTYPE},${SUBCHANNELS}${_options} > ${initdir}/etc/cmdline.d/30znet.conf
|
|
|
ab224c |
}
|
|
|
ab224c |
|
|
|
ab224c |
# Setup dracut to bringup a given network interface
|
|
|
ab224c |
kdump_setup_netdev() {
|
|
|
3dae34 |
local _netdev=$1 _srcaddr=$2
|
|
|
765b01 |
local _static _proto _ip_conf _ip_opts _ifname_opts
|
|
|
ab224c |
|
|
|
ab224c |
if [ "$(uname -m)" = "s390x" ]; then
|
|
|
ab224c |
kdump_setup_znet $_netdev
|
|
|
ab224c |
fi
|
|
|
ab224c |
|
|
|
ab224c |
_netmac=$(kdump_get_mac_addr $_netdev)
|
|
|
3dae34 |
_static=$(kdump_static_ip $_netdev $_srcaddr)
|
|
|
ab224c |
if [ -n "$_static" ]; then
|
|
|
ab224c |
_proto=none
|
|
|
ab224c |
else
|
|
|
ab224c |
_proto=dhcp
|
|
|
ab224c |
fi
|
|
|
ab224c |
|
|
|
765b01 |
_ip_conf="${initdir}/etc/cmdline.d/40ip.conf"
|
|
|
a465a3 |
_ip_opts=" ip=${_static}$(kdump_setup_ifname $_netdev):${_proto}"
|
|
|
765b01 |
|
|
|
765b01 |
# dracut doesn't allow duplicated configuration for same NIC, even they're exactly the same.
|
|
|
765b01 |
# so we have to avoid adding duplicates
|
|
|
929c78 |
# We should also check /proc/cmdline for existing ip=xx arg.
|
|
|
929c78 |
# For example, iscsi boot will specify ip=xxx arg in cmdline.
|
|
|
929c78 |
if [ ! -f $_ip_conf ] || ! grep -q $_ip_opts $_ip_conf &&\
|
|
|
929c78 |
! grep -q "ip=[^[:space:]]*$_netdev" /proc/cmdline; then
|
|
|
765b01 |
echo "$_ip_opts" >> $_ip_conf
|
|
|
765b01 |
fi
|
|
|
ab224c |
|
|
|
ab224c |
if kdump_is_bridge "$_netdev"; then
|
|
|
ab224c |
kdump_setup_bridge "$_netdev"
|
|
|
ab224c |
elif kdump_is_bond "$_netdev"; then
|
|
|
ab224c |
kdump_setup_bond "$_netdev"
|
|
|
ab224c |
elif kdump_is_team "$_netdev"; then
|
|
|
ab224c |
kdump_setup_team "$_netdev"
|
|
|
ab224c |
elif kdump_is_vlan "$_netdev"; then
|
|
|
ab224c |
kdump_setup_vlan "$_netdev"
|
|
|
ab224c |
else
|
|
|
a465a3 |
_ifname_opts=" ifname=$(kdump_setup_ifname $_netdev):$(kdump_get_mac_addr $_netdev)"
|
|
|
765b01 |
echo "$_ifname_opts" >> $_ip_conf
|
|
|
ab224c |
fi
|
|
|
ab224c |
|
|
|
ab224c |
kdump_setup_dns "$_netdev"
|
|
|
ab224c |
}
|
|
|
ab224c |
|
|
|
ab224c |
#Function:kdump_install_net
|
|
|
ab224c |
#$1: config values of net line in kdump.conf
|
|
|
3dae34 |
#$2: srcaddr of network device
|
|
|
ab224c |
kdump_install_net() {
|
|
|
3dae34 |
local _server _netdev _srcaddr
|
|
|
ab224c |
local config_val="$1"
|
|
|
ab224c |
|
|
|
ab224c |
_server=`echo $config_val | sed 's/.*@//' | cut -d':' -f1`
|
|
|
ab224c |
|
|
|
ab224c |
_need_dns=`echo $_server|grep "[a-zA-Z]"`
|
|
|
ab224c |
[ -n "$_need_dns" ] && _server=`getent hosts $_server|cut -d' ' -f1`
|
|
|
ab224c |
|
|
|
ab224c |
_netdev=`/sbin/ip route get to $_server 2>&1`
|
|
|
ab224c |
[ $? != 0 ] && echo "Bad kdump location: $config_val" && exit 1
|
|
|
ab224c |
|
|
|
ab224c |
#the field in the ip output changes if we go to another subnet
|
|
|
ab224c |
if [ -n "`echo $_netdev | grep via`" ]
|
|
|
ab224c |
then
|
|
|
ab224c |
# we are going to a different subnet
|
|
|
3dae34 |
_srcaddr=`echo $_netdev|awk '{print $7}'|head -n 1`
|
|
|
ab224c |
_netdev=`echo $_netdev|awk '{print $5;}'|head -n 1`
|
|
|
ab224c |
else
|
|
|
ab224c |
# we are on the same subnet
|
|
|
3dae34 |
_srcaddr=`echo $_netdev|awk '{print $5}'|head -n 1`
|
|
|
ab224c |
_netdev=`echo $_netdev|awk '{print $3}'|head -n 1`
|
|
|
ab224c |
fi
|
|
|
ab224c |
|
|
|
3dae34 |
kdump_setup_netdev "${_netdev}" "${_srcaddr}"
|
|
|
765b01 |
|
|
|
ab224c |
#save netdev used for kdump as cmdline
|
|
|
765b01 |
# Whoever calling kdump_install_net() is setting up the default gateway,
|
|
|
765b01 |
# ie. bootdev/kdumpnic. So don't override the setting if calling
|
|
|
765b01 |
# kdump_install_net() for another time. For example, after setting eth0 as
|
|
|
765b01 |
# the default gate way for network dump, eth1 in the fence kdump path will
|
|
|
765b01 |
# call kdump_install_net again and we don't want eth1 to be the default
|
|
|
765b01 |
# gateway.
|
|
|
765b01 |
if [ ! -f ${initdir}${initdir}/etc/cmdline.d/60kdumpnic.conf ] &&
|
|
|
765b01 |
[ ! -f ${initdir}/etc/cmdline.d/70bootdev.conf ]; then
|
|
|
a465a3 |
echo "kdumpnic=$(kdump_setup_ifname $_netdev)" > ${initdir}/etc/cmdline.d/60kdumpnic.conf
|
|
|
a465a3 |
echo "bootdev=$(kdump_setup_ifname $_netdev)" > ${initdir}/etc/cmdline.d/70bootdev.conf
|
|
|
765b01 |
fi
|
|
|
ab224c |
}
|
|
|
ab224c |
|
|
|
ab224c |
#install kdump.conf and what user specifies in kdump.conf
|
|
|
ab224c |
kdump_install_conf() {
|
|
|
ab224c |
sed -ne '/^#/!p' /etc/kdump.conf > /tmp/$$-kdump.conf
|
|
|
ab224c |
|
|
|
ab224c |
while read config_opt config_val;
|
|
|
ab224c |
do
|
|
|
ab224c |
# remove inline comments after the end of a directive.
|
|
|
ab224c |
config_val=$(strip_comments $config_val)
|
|
|
ab224c |
case "$config_opt" in
|
|
|
ab224c |
ext[234]|xfs|btrfs|minix|raw)
|
|
|
ab224c |
sed -i -e "s#$config_val#$(kdump_to_udev_name $config_val)#" /tmp/$$-kdump.conf
|
|
|
ab224c |
;;
|
|
|
ab224c |
ssh|nfs)
|
|
|
ab224c |
kdump_install_net "$config_val"
|
|
|
ab224c |
;;
|
|
|
ab224c |
kdump_pre|kdump_post|extra_bins)
|
|
|
ab224c |
dracut_install $config_val
|
|
|
ab224c |
;;
|
|
|
ab224c |
core_collector)
|
|
|
ab224c |
dracut_install "${config_val%%[[:blank:]]*}"
|
|
|
ab224c |
;;
|
|
|
ab224c |
esac
|
|
|
ab224c |
done < /etc/kdump.conf
|
|
|
ab224c |
|
|
|
765b01 |
kdump_check_fence_kdump
|
|
|
ab224c |
inst "/tmp/$$-kdump.conf" "/etc/kdump.conf"
|
|
|
ab224c |
rm -f /tmp/$$-kdump.conf
|
|
|
ab224c |
}
|
|
|
ab224c |
|
|
|
ab224c |
kdump_iscsi_get_rec_val() {
|
|
|
ab224c |
|
|
|
ab224c |
local result
|
|
|
ab224c |
|
|
|
ab224c |
# The open-iscsi 742 release changed to using flat files in
|
|
|
ab224c |
# /var/lib/iscsi.
|
|
|
ab224c |
|
|
|
ab224c |
result=$(/sbin/iscsiadm --show -m session -r ${1} | grep "^${2} = ")
|
|
|
ab224c |
result=${result##* = }
|
|
|
ab224c |
echo $result
|
|
|
ab224c |
}
|
|
|
ab224c |
|
|
|
ab224c |
kdump_get_iscsi_initiator() {
|
|
|
ab224c |
local _initiator
|
|
|
ab224c |
local initiator_conf="/etc/iscsi/initiatorname.iscsi"
|
|
|
ab224c |
|
|
|
ab224c |
[ -f "$initiator_conf" ] || return 1
|
|
|
ab224c |
|
|
|
ab224c |
while read _initiator; do
|
|
|
ab224c |
[ -z "${_initiator%%#*}" ] && continue # Skip comment lines
|
|
|
ab224c |
|
|
|
ab224c |
case $_initiator in
|
|
|
ab224c |
InitiatorName=*)
|
|
|
ab224c |
initiator=${_initiator#InitiatorName=}
|
|
|
ab224c |
echo "rd.iscsi.initiator=${initiator}"
|
|
|
ab224c |
return 0;;
|
|
|
ab224c |
*) ;;
|
|
|
ab224c |
esac
|
|
|
ab224c |
done < ${initiator_conf}
|
|
|
ab224c |
|
|
|
ab224c |
return 1
|
|
|
ab224c |
}
|
|
|
ab224c |
|
|
|
ab224c |
# No ibft handling yet.
|
|
|
ab224c |
kdump_setup_iscsi_device() {
|
|
|
ab224c |
local path=$1
|
|
|
ab224c |
local tgt_name; local tgt_ipaddr;
|
|
|
ab224c |
local username; local password; local userpwd_str;
|
|
|
ab224c |
local username_in; local password_in; local userpwd_in_str;
|
|
|
ab224c |
local netdev
|
|
|
3dae34 |
local srcaddr
|
|
|
ab224c |
local idev
|
|
|
ab224c |
local netroot_str ; local initiator_str;
|
|
|
ab224c |
local netroot_conf="${initdir}/etc/cmdline.d/50iscsi.conf"
|
|
|
ab224c |
local initiator_conf="/etc/iscsi/initiatorname.iscsi"
|
|
|
ab224c |
|
|
|
ab224c |
dinfo "Found iscsi component $1"
|
|
|
ab224c |
|
|
|
ab224c |
# Check once before getting explicit values, so we can output a decent
|
|
|
ab224c |
# error message.
|
|
|
ab224c |
|
|
|
ab224c |
if ! /sbin/iscsiadm -m session -r ${path} >/dev/null ; then
|
|
|
ab224c |
derror "Unable to find iscsi record for $path"
|
|
|
ab224c |
return 1
|
|
|
ab224c |
fi
|
|
|
ab224c |
|
|
|
ab224c |
tgt_name=$(kdump_iscsi_get_rec_val ${path} "node.name")
|
|
|
ab224c |
tgt_ipaddr=$(kdump_iscsi_get_rec_val ${path} "node.conn\[0\].address")
|
|
|
ab224c |
|
|
|
ab224c |
# get and set username and password details
|
|
|
ab224c |
username=$(kdump_iscsi_get_rec_val ${path} "node.session.auth.username")
|
|
|
ab224c |
[ "$username" == "<empty>" ] && username=""
|
|
|
ab224c |
password=$(kdump_iscsi_get_rec_val ${path} "node.session.auth.password")
|
|
|
ab224c |
[ "$password" == "<empty>" ] && password=""
|
|
|
ab224c |
username_in=$(kdump_iscsi_get_rec_val ${path} "node.session.auth.username_in")
|
|
|
ab224c |
[ -n "$username" ] && userpwd_str="$username:$password"
|
|
|
ab224c |
|
|
|
ab224c |
# get and set incoming username and password details
|
|
|
ab224c |
[ "$username_in" == "<empty>" ] && username_in=""
|
|
|
ab224c |
password_in=$(kdump_iscsi_get_rec_val ${path} "node.session.auth.password_in")
|
|
|
ab224c |
[ "$password_in" == "<empty>" ] && password_in=""
|
|
|
ab224c |
|
|
|
ab224c |
[ -n "$username_in" ] && userpwd_in_str=":$username_in:$password_in"
|
|
|
ab224c |
|
|
|
ab224c |
netdev=$(/sbin/ip route get to ${tgt_ipaddr} | \
|
|
|
3dae34 |
sed 's|.*dev \(.*\).*|\1|g')
|
|
|
3dae34 |
srcaddr=$(echo $netdev | awk '{ print $3; exit }')
|
|
|
3dae34 |
netdev=$(echo $netdev | awk '{ print $1; exit }')
|
|
|
ab224c |
|
|
|
3dae34 |
kdump_setup_netdev $netdev $srcaddr
|
|
|
ab224c |
|
|
|
ab224c |
# prepare netroot= command line
|
|
|
ab224c |
# FIXME: IPV6 addresses require explicit [] around $tgt_ipaddr
|
|
|
ab224c |
# FIXME: Do we need to parse and set other parameters like protocol, port
|
|
|
ab224c |
# iscsi_iface_name, netdev_name, LUN etc.
|
|
|
ab224c |
|
|
|
ab224c |
netroot_str="netroot=iscsi:${userpwd_str}${userpwd_in_str}@$tgt_ipaddr::::$tgt_name"
|
|
|
ab224c |
|
|
|
ab224c |
[[ -f $netroot_conf ]] || touch $netroot_conf
|
|
|
ab224c |
|
|
|
ab224c |
# If netroot target does not exist already, append.
|
|
|
ab224c |
if ! grep -q $netroot_str $netroot_conf; then
|
|
|
ab224c |
echo $netroot_str >> $netroot_conf
|
|
|
ab224c |
dinfo "Appended $netroot_str to $netroot_conf"
|
|
|
ab224c |
fi
|
|
|
ab224c |
|
|
|
ab224c |
# Setup initator
|
|
|
ab224c |
initiator_str=$(kdump_get_iscsi_initiator)
|
|
|
ab224c |
[ $? -ne "0" ] && derror "Failed to get initiator name" && return 1
|
|
|
ab224c |
|
|
|
ab224c |
# If initiator details do not exist already, append.
|
|
|
ab224c |
if ! grep -q "$initiator_str" $netroot_conf; then
|
|
|
ab224c |
echo "$initiator_str" >> $netroot_conf
|
|
|
ab224c |
dinfo "Appended "$initiator_str" to $netroot_conf"
|
|
|
ab224c |
fi
|
|
|
ab224c |
}
|
|
|
ab224c |
|
|
|
ab224c |
kdump_check_iscsi_targets () {
|
|
|
ab224c |
# If our prerequisites are not met, fail anyways.
|
|
|
ab224c |
type -P iscsistart >/dev/null || return 1
|
|
|
ab224c |
|
|
|
ab224c |
kdump_check_setup_iscsi() (
|
|
|
ab224c |
local _dev
|
|
|
ab224c |
_dev=$1
|
|
|
ab224c |
|
|
|
ab224c |
[[ -L /sys/dev/block/$_dev ]] || return
|
|
|
ab224c |
cd "$(readlink -f /sys/dev/block/$_dev)"
|
|
|
ab224c |
until [[ -d sys || -d iscsi_session ]]; do
|
|
|
ab224c |
cd ..
|
|
|
ab224c |
done
|
|
|
ab224c |
[[ -d iscsi_session ]] && kdump_setup_iscsi_device "$PWD"
|
|
|
ab224c |
)
|
|
|
ab224c |
|
|
|
ab224c |
[[ $hostonly ]] || [[ $mount_needs ]] && {
|
|
|
ab224c |
for_each_host_dev_and_slaves_all kdump_check_setup_iscsi
|
|
|
ab224c |
}
|
|
|
ab224c |
}
|
|
|
ab224c |
|
|
|
ab224c |
|
|
|
765b01 |
# setup fence_kdump in cluster
|
|
|
765b01 |
# setup proper network and install needed files
|
|
|
765b01 |
# also preserve '[node list]' for 2nd kernel /etc/fence_kdump_nodes
|
|
|
765b01 |
kdump_check_fence_kdump () {
|
|
|
765b01 |
local nodes
|
|
|
765b01 |
is_fence_kdump || return 1
|
|
|
765b01 |
|
|
|
765b01 |
# get cluster nodes from cluster cib, get interface and ip address
|
|
|
765b01 |
nodelist=`pcs cluster cib | xmllint --xpath "/cib/status/node_state/@uname" -`
|
|
|
765b01 |
|
|
|
765b01 |
# nodelist is formed as 'uname="node1" uname="node2" ... uname="nodeX"'
|
|
|
765b01 |
# we need to convert each to node1, node2 ... nodeX in each iteration
|
|
|
765b01 |
for node in ${nodelist}; do
|
|
|
765b01 |
# convert $node from 'uname="nodeX"' to 'nodeX'
|
|
|
765b01 |
eval $node
|
|
|
765b01 |
nodename=$uname
|
|
|
765b01 |
# Skip its own node name
|
|
|
765b01 |
if [ "$nodename" = `hostname` ]; then
|
|
|
765b01 |
continue
|
|
|
765b01 |
fi
|
|
|
765b01 |
nodes="$nodes $nodename"
|
|
|
765b01 |
|
|
|
765b01 |
kdump_install_net $nodename
|
|
|
765b01 |
done
|
|
|
765b01 |
echo
|
|
|
765b01 |
|
|
|
765b01 |
echo "$nodes" > ${initdir}/$FENCE_KDUMP_NODES
|
|
|
765b01 |
dracut_install $FENCE_KDUMP_SEND
|
|
|
765b01 |
dracut_install -o $FENCE_KDUMP_CONFIG
|
|
|
765b01 |
}
|
|
|
765b01 |
|
|
|
765b01 |
# Install a random seed used to feed /dev/urandom
|
|
|
765b01 |
# By the time kdump service starts, /dev/uramdom is already fed by systemd
|
|
|
765b01 |
kdump_install_random_seed() {
|
|
|
765b01 |
local poolsize=`cat /proc/sys/kernel/random/poolsize`
|
|
|
765b01 |
|
|
|
765b01 |
if [ ! -d ${initdir}/var/lib/ ]; then
|
|
|
765b01 |
mkdir -p ${initdir}/var/lib/
|
|
|
765b01 |
fi
|
|
|
765b01 |
|
|
|
765b01 |
dd if=/dev/urandom of=${initdir}/var/lib/random-seed \
|
|
|
765b01 |
bs=$poolsize count=1 2> /dev/null
|
|
|
765b01 |
}
|
|
|
765b01 |
|
|
|
ab224c |
install() {
|
|
|
ab224c |
kdump_install_conf
|
|
|
ab224c |
>"$initdir/lib/dracut/no-emergency-shell"
|
|
|
ab224c |
|
|
|
ab224c |
if is_ssh_dump_target; then
|
|
|
765b01 |
kdump_install_random_seed
|
|
|
ab224c |
fi
|
|
|
ab224c |
dracut_install -o /etc/adjtime /etc/localtime
|
|
|
ab224c |
inst "$moddir/monitor_dd_progress" "/kdumpscripts/monitor_dd_progress"
|
|
|
ab224c |
chmod +x ${initdir}/kdumpscripts/monitor_dd_progress
|
|
|
ab224c |
inst "/bin/dd" "/bin/dd"
|
|
|
ab224c |
inst "/bin/tail" "/bin/tail"
|
|
|
ab224c |
inst "/bin/date" "/bin/date"
|
|
|
ab224c |
inst "/bin/sync" "/bin/sync"
|
|
|
ab224c |
inst "/bin/cut" "/bin/cut"
|
|
|
ab224c |
inst "/sbin/makedumpfile" "/sbin/makedumpfile"
|
|
|
ab224c |
inst "/sbin/vmcore-dmesg" "/sbin/vmcore-dmesg"
|
|
|
ab224c |
inst_hook pre-pivot 9999 "$moddir/kdump.sh"
|
|
|
ab224c |
inst "/lib/kdump/kdump-lib.sh" "/lib/kdump-lib.sh"
|
|
|
ab224c |
|
|
|
ab224c |
# Check for all the devices and if any device is iscsi, bring up iscsi
|
|
|
ab224c |
# target. Ideally all this should be pushed into dracut iscsi module
|
|
|
ab224c |
# at some point of time.
|
|
|
ab224c |
kdump_check_iscsi_targets
|
|
|
ab224c |
}
|
|
|
765b01 |
|
|
|
765b01 |
installkernel() {
|
|
|
765b01 |
wdt=$(lsmod|cut -f1 -d' '|grep "wdt$")
|
|
|
765b01 |
if [ -n "$wdt" ]; then
|
|
|
765b01 |
[ "$wdt" = "iTCO_wdt" ] && instmods lpc_ich
|
|
|
765b01 |
instmods $wdt
|
|
|
765b01 |
fi
|
|
|
765b01 |
}
|