ab224c
#!/bin/sh
ab224c
#
765b01
# Kdump common variables and functions
ab224c
#
ab224c
765b01
FENCE_KDUMP_CONFIG="/etc/sysconfig/fence_kdump"
765b01
FENCE_KDUMP_SEND="/usr/libexec/fence_kdump_send"
765b01
FENCE_KDUMP_NODES="/etc/fence_kdump_nodes"
765b01
ab224c
is_ssh_dump_target()
ab224c
{
ab224c
    grep -q "^ssh[[:blank:]].*@" /etc/kdump.conf
ab224c
}
ab224c
ab224c
is_nfs_dump_target()
ab224c
{
ab224c
    grep -q "^nfs" /etc/kdump.conf
ab224c
}
ab224c
ab224c
is_raw_dump_target()
ab224c
{
ab224c
    grep -q "^raw" /etc/kdump.conf
ab224c
}
ab224c
ab224c
strip_comments()
ab224c
{
ab224c
    echo $@ | sed -e 's/\(.*\)#.*/\1/'
ab224c
}
765b01
765b01
# Check if fence kdump is configured in cluster
765b01
is_fence_kdump()
765b01
{
765b01
    # no pcs or fence_kdump_send executables installed?
765b01
    type -P pcs > /dev/null || return 1
765b01
    [ -x $FENCE_KDUMP_SEND ] || return 1
765b01
765b01
    # fence kdump not configured?
765b01
    (pcs cluster cib | grep -q 'type="fence_kdump"') &> /dev/null || return 1
765b01
}
765b01
765b01
get_user_configured_dump_disk()
765b01
{
765b01
    local _target
765b01
765b01
    if is_ssh_dump_target || is_nfs_dump_target; then
765b01
        return
765b01
    fi
765b01
765b01
    _target=$(egrep "^ext[234]|^xfs|^btrfs|^minix|^raw" /etc/kdump.conf 2>/dev/null |awk '{print $2}')
765b01
    [ -n "$_target" ] && echo $_target
765b01
765b01
    return
765b01
}
765b01
765b01
is_user_configured_dump_target()
765b01
{
765b01
    local _target
765b01
765b01
    if is_ssh_dump_target || is_nfs_dump_target; then
765b01
        return 0
765b01
    fi
765b01
765b01
    _target=$(egrep "^ext[234]|^xfs|^btrfs|^minix|^raw" /etc/kdump.conf 2>/dev/null |awk '{print $2}')
765b01
    [ -n "$_target" ] && return 0
765b01
765b01
    return 1
765b01
}
765b01
765b01
get_root_fs_device()
765b01
{
765b01
    local _target
765b01
    _target=$(findmnt -k -f -n -o SOURCE /)
765b01
    [ -n "$_target" ] && echo $_target
765b01
765b01
    return
765b01
}
765b01