# getOSType.sh

#!/bin/bash
#Author:        ...
#CreateDate:    2014-08-26
#Environment:   Linux + Bash
function Successful()
{
    [ $? -eq 0 ] && return 0
    return 1
}
function GetOSName()
{
    local l_OSName="unknown"
    local l_ReleaseInfo
    l_ReleaseInfo=$(cat  /etc/redhat-release  2>/dev/null)
    if ! Successful; then
        echo ${l_OSName}
        return 1;
    fi
    echo ${l_ReleaseInfo} |grep -i "Red Hat Linux" >/dev/null 2>&1
    if Successful; then
        l_OSName='redhat'
    fi
    echo ${l_ReleaseInfo} |grep -i "CentOS" >/dev/null 2>&1
    if Successful; then
        l_OSName='centos'
    fi
    l_Version=$(echo ${l_ReleaseInfo}|sed -e "s#^.*[ ]\([0-9.]\{1,\}\)[ ].*#\1#g")
    if [ "${l_Version}" == "${l_ReleaseInfo}" ]; then
        l_Version=''
    fi
    l_Arch='32'
    uname -p 2>/dev/null |grep -i 'x86_64' > /dev/null 2>&1
    if Successful; then
        l_Arch="64"
    fi
    echo ${l_OSName}${l_Version}_${l_Arch} 
}
GetOSName