WANG Chao a8921f0
#!/bin/sh
WANG Chao a8921f0
#
WANG Chao b0535af
# Kdump common variables and functions
WANG Chao a8921f0
#
WANG Chao a8921f0
98d4be9
FENCE_KDUMP_CONFIG_FILE="/etc/sysconfig/fence_kdump"
WANG Chao b0535af
FENCE_KDUMP_SEND="/usr/libexec/fence_kdump_send"
WANG Chao b0535af
WANG Chao a8921f0
is_ssh_dump_target()
WANG Chao a8921f0
{
WANG Chao a8921f0
    grep -q "^ssh[[:blank:]].*@" /etc/kdump.conf
WANG Chao a8921f0
}
WANG Chao a8921f0
WANG Chao a8921f0
is_nfs_dump_target()
WANG Chao a8921f0
{
WANG Chao a8921f0
    grep -q "^nfs" /etc/kdump.conf
WANG Chao a8921f0
}
WANG Chao a8921f0
WANG Chao a8921f0
is_raw_dump_target()
WANG Chao a8921f0
{
WANG Chao a8921f0
    grep -q "^raw" /etc/kdump.conf
WANG Chao a8921f0
}
Baoquan He ee52447
Baoquan He ee52447
strip_comments()
Baoquan He ee52447
{
Baoquan He a682315
    echo $@ | sed -e 's/\(.*\)#.*/\1/'
Baoquan He ee52447
}
WANG Chao b0535af
98f58cd
# Check if fence kdump is configured in Pacemaker cluster
98f58cd
is_pcs_fence_kdump()
WANG Chao b0535af
{
WANG Chao b0535af
    # no pcs or fence_kdump_send executables installed?
WANG Chao b0535af
    type -P pcs > /dev/null || return 1
WANG Chao b0535af
    [ -x $FENCE_KDUMP_SEND ] || return 1
WANG Chao b0535af
WANG Chao b0535af
    # fence kdump not configured?
WANG Chao b0535af
    (pcs cluster cib | grep -q 'type="fence_kdump"') &> /dev/null || return 1
WANG Chao b0535af
}
Baoquan He 8c527ab
2066e5f
# Check if fence_kdump is configured using kdump options
2066e5f
is_generic_fence_kdump()
2066e5f
{
2066e5f
    [ -x $FENCE_KDUMP_SEND ] || return 1
2066e5f
2066e5f
    grep -q "^fence_kdump_nodes" /etc/kdump.conf
2066e5f
}
2066e5f
Baoquan He 8c527ab
get_user_configured_dump_disk()
Baoquan He 8c527ab
{
Baoquan He 8c527ab
    local _target
Baoquan He 8c527ab
Baoquan He 8c527ab
    if is_ssh_dump_target || is_nfs_dump_target; then
Baoquan He 8c527ab
        return
Baoquan He 8c527ab
    fi
Baoquan He 8c527ab
Baoquan He 8c527ab
    _target=$(egrep "^ext[234]|^xfs|^btrfs|^minix|^raw" /etc/kdump.conf 2>/dev/null |awk '{print $2}')
Baoquan He 8c527ab
    [ -n "$_target" ] && echo $_target
Baoquan He 8c527ab
Baoquan He 8c527ab
    return
Baoquan He 8c527ab
}
Baoquan He 8c527ab
Baoquan He c1bf4de
is_user_configured_dump_target()
Baoquan He c1bf4de
{
Baoquan He c1bf4de
    local _target
Baoquan He c1bf4de
Baoquan He c1bf4de
    if is_ssh_dump_target || is_nfs_dump_target; then
Baoquan He c1bf4de
        return 0
Baoquan He c1bf4de
    fi
Baoquan He c1bf4de
Baoquan He c1bf4de
    _target=$(egrep "^ext[234]|^xfs|^btrfs|^minix|^raw" /etc/kdump.conf 2>/dev/null |awk '{print $2}')
Baoquan He c1bf4de
    [ -n "$_target" ] && return 0
Baoquan He c1bf4de
Baoquan He c1bf4de
    return 1
Baoquan He c1bf4de
}
Baoquan He c1bf4de
Baoquan He 8c527ab
get_root_fs_device()
Baoquan He 8c527ab
{
Baoquan He 8c527ab
    local _target
Baoquan He 8c527ab
    _target=$(findmnt -k -f -n -o SOURCE /)
Baoquan He 8c527ab
    [ -n "$_target" ] && echo $_target
Baoquan He 8c527ab
Baoquan He 8c527ab
    return
Baoquan He 8c527ab
}
Baoquan He 8c527ab
b8d586d
# get_option_value <option_name>
b8d586d
# retrieves value of option defined in kdump.conf
b8d586d
get_option_value() {
b8d586d
    echo $(strip_comments `grep ^$1 /etc/kdump.conf | tail -1 | cut -d\  -f2-`)
b8d586d
}
b8d586d