

if [ "${g30s_systemEnvironment}" = "" ]
then
    g30s_systemEnvironment="yes"
    g10s_LIBFILE=${g10s_LIBFILE="../globalLib/g10s_pub"}
    if [ -f "${g10s_LIBFILE}" ]
    then
        G10S_CUR_DIR="${g10s_LIBFILE}"
        . "${g10s_LIBFILE}"
    else
        fileFlag="g30s"
    	echo -e "\033[31m[ERROR:15][${fileFlag}][`date +%Y%m%d%H%M%S`][$0,${FUNCNAME[1]},${BASH_LINENO[0]}] not found the lib[${g10s_LIBFILE}]\033[0m"
    	eval "${g10s_exitFun} 1"
    fi
       

    g30s_initiatorType=","
        

    function g30s_checkMultiChannel()
    {   
        local iCount=0
        g30s_initiatorType=","
        
        [ `lspci|grep -c "Fibre"` -ne 0 ] && g30s_initiatorType="${g30s_initiatorType}FC,"
        
        if [ `iscsiadm -m node 2>/dev/null|wc -l` -ne 0 ]
        then
            g30s_initiatorType="${g30s_initiatorType}ISCSI,"
        fi
        
        iCount=`echo "${g30s_initiatorType}"|awk -F "," '{print NF}'`
        if [ ${iCount} -ge 4 ]
        then
            print_warning "1001" "both found iscsi nodes and Fibre Channel,You can only use one of them." "g30s"
            return 1
        fi
        return 0
    }
    
    function g30s_checkOtherMutiPath()
    {
        if [ `rpm -qa|grep -E -c "EMCpower"` -ne 0 ]
        then
    	    print_warning "1002" "A PowerPath driver is detected on your system, it will conflict with UltraPath." "g30s"
            eval "${g10s_exitFun} 1"
        fi
        return 0
    }
    
    function g30s_checkRDAC()
    {
        local reta
        local retb
        local unameret
        local ret
        
        reta=`lsmod | awk '{print $1}' | grep mppUpper | wc -l`
        retb=`lsmod | awk '{print $1}' | grep mppVhba | wc -l`
        if [ $reta -gt 0 ] || [ $retb -gt 0 ]
        then
           print_warning "1003" "RDAC is running in system" "g30s"
           eval "${g10s_exitFun} 1"
        fi
        unameret=`uname -r`
        ret=`ls /lib/modules/${unameret}/kernel/drivers/scsi/|grep -E -c "^(mppUpper|mppVhba)\.ko"`
        if [ $ret -gt 1 ]
        then
           print_warning "1004" "RDAC was installed in system" "g30s"
           return 1
        fi
        return 0
    }
    
    function g30s_createWhiteList()
    {
        local line
        if [ ! -f "$1" ]
        then
            return
        fi    
        echo "" > ${2}
        while read line
        do
            line=$(echo ${line})
            if [ -z "${line}" ]
            then
                continue
            fi
            echo "${line}" >> ${2}
        done < "${1}"
    }

    function g30s_isSanBootOnline()
    {
        local diskLabel
        local diskVendor
        local diskProduct
        local tmpVendor
        local ret

        diskLabel=`df /|grep "/dev/sd.*"|awk '{print $1}'`
        if [ "${diskLabel}" != "" ]
        then
            diskLabel=${diskLabel%%[0-9]*}
            diskLabel=${diskLabel##*/}
            diskLabel=$(echo ${diskLabel})
        fi
        
        if [ `echo "${diskLabel}"|grep -E -c "^sd[a-zA-Z]+$"` -eq 0 ] || [ ! -e /sys/block/${diskLabel}/device/vendor ] || [ ! -e /sys/block/${diskLabel}/device/model ]
        then
            return 2
        fi
        
        g30s_createWhiteList "${i10s_decompressDir}/UltraPath/install/up.conf" "/tmp/upWhiteList.1"
        g30s_createWhiteList "/etc/up.conf.save_r8_999" "/tmp/upWhiteList.2"
        
        diskVendor=`cat /sys/block/${diskLabel}/device/vendor`
        diskVendor=$(echo ${diskVendor})
        diskProduct=`cat /sys/block/${diskLabel}/device/model`
        diskProduct=$(echo ${diskProduct})

        ret=`cat "/tmp/upWhiteList*" 2>/dev/null | grep -c "vendor_id *= *\"${thisVendor}\"[, ]*product_id *= *\"${thisProduct}\""`
        rm -rf /tmp/upWhiteList*
        if [ ${ret} -gt 0 ]
        then
            print_event "1005" "this system is boot-from-SAN system.[${diskLabel},${diskVendor}]" "g30s"
            return 1
        else
            return 2
        fi

        print_debug "this system is boot-from-local." "g30s"
        return 0
    }

    function g30s_IsSupportSanbootOs()
    {
        local ret
        g10s_getOSType
        ret=`cat /etc/SD100_Release 2>/dev/null | grep -c "SD100"`
        if [ ${ret} -eq 0 ] && [ `echo "${g10s_OSVersion}" | grep -c "ROCKY_6.0.42"` -eq 0 ]
        then
            return 1 
        else
            return 0
        fi
    }

    g30s_isSanBoot=""
    function g30s_getIsSanBoot()
    {
        local ret

    	ret=`cat ${g10s_ultraPathPackagesInfo} | grep -c "^[[:blank:]]*g30s_isSanBoot"`
    	if [ ${ret} -eq 0 ]
    	then
    	    g30s_isSanBootOnline
    	    g30s_isSanBoot="$?"
    	else
    	    g10s_getConf "${g10s_ultraPathPackagesInfo}" "g30s_isSanBoot"
    	    if [ "${g10s_confValue}" != "" ]
    	    then
    	        g30s_isSanBoot="${g10s_confValue}"
    	    fi
    	fi

    	if [ "${g30s_isSanBoot}" = "0" ] || [ "${g30s_isSanBoot}" = "1" ]
    	then 
    	    return 0
    	fi
    	
    	if [ "${g30s_isSanBoot}" != "0" ] && [ "${g30s_isSanBoot}" != "1" ]
    	then

    	    g10s_getConf "${g10s_ultraPathPackagesInfo}" "g10s_OSVersion"
    	    if [ "${g10s_confValue}" != "" ]
    	    then
    	        if [ "${g10s_confValue}" = "SLES10SP2" ]
    	        then
    	            print_warning "1004" "This kernel has a defect for scaning LUNs,you had better select boot-from-SAN to install." "g30s"
    	        fi
    	    fi
    	        	    

            g10s_defaultSelect="1"
    	    g10s_singleSelectSets=("1" "boot-from-Local" \
                                "2" "boot-from-SAN")
            echo "If the operating system is installed on a local drive of the server, you are advised"
            echo "to choose boot from local; if the operating system is installed on a SAN storage" 	
            if [ "${UnattendInstallUltraPathFlag}" = "1" ]
            then
                echo "system, you must choose boot from san. Please choose the boot type of your system:" 
                echo  "<1>--boot-from-Local" 
                echo  "<2>--boot-from-SAN" 
                echo  "please input your select:${SystemBootType}" 
                if [ "${SystemBootType}" = "1" ]
                then
                    g30s_isSanBoot="0"
                    print_event "2007" "Unattend install configuration item 'boot_type' set to '1'. Unattend installation will continue." "g30s"
                elif [ "${SystemBootType}" = "2" ]
                then
                    g30s_isSanBoot="1"
                    print_event "2007" "Unattend install configuration item 'boot_type' set to '2'. Unattend installation will continue." "g30s"
                else
                    print_error "1007" "get g30s_isSanBoot failed." "g30s" 
                    eval "${g10s_exitFun} 1"
                fi
            else
                print_singleSelect "1006" "system, you must choose boot from san. Please choose the boot type of your system:" "g30s"
    
                ret=$?
                if [ ${ret} -eq 3 ]
                then
                    eval "${g10s_exitFun} 2"
                elif [ ${ret} -eq 2 ]
                then
                    g30s_isSanBoot="1"
                elif [ ${ret} -eq 1 ]
                then
                    g30s_isSanBoot="0"
                else
                    print_error "1007" "get g30s_isSanBoot failed." "g30s" 
                    eval "${g10s_exitFun} 1"
                fi
            fi
    	fi
    	
    	g10s_saveConf "${g10s_ultraPathPackagesInfo}" "g30s_isSanBoot" "${g30s_isSanBoot}" 
    	return 0
    }



    g30s_bootLoaderType=","


    function g30s_getBootLoaderTypeOnline()
    {
        local efimountinfo
        g30s_bootLoaderType=","

        if [ -f /boot/grub/menu.lst ] && [ ! -L /boot/grub/menu.lst ]
        then
            if [ -f /boot/grub/grub.conf ] && [ ! -L /boot/grub/grub.conf ]
            then
                print_error "1008" "Both /boot/grub/menu.lst and /boot/grub/grub.conf coexist and are not linked file,the OS may be destroyed.it is recommended to re-install UltraPath after one of them created as linked file" "g30s"
                exit 1
            fi
            g30s_bootLoaderType="${g30s_bootLoaderType}grub,"
        fi
        

        if [ -f /boot/grub/menu.lst ] && [ `ls -l /boot/grub/menu.lst|grep -c -E "/boot/grub/menu.lst[[:blank:]]*->.*/grub.conf|/boot/grub/menu.lst[[:blank:]]*->[[:blank:]]*grub.conf"` -eq 1 ]
        then
            g30s_bootLoaderType="${g30s_bootLoaderType}grub,"
        fi
        

        if [ -f /etc/lilo.conf ]
        then
           g30s_bootLoaderType="${g30s_bootLoaderType}lilo,"
        fi
        

        if [ -f /etc/elilo.conf ]
        then
           g30s_bootLoaderType="${g30s_bootLoaderType}elilo,"
        fi
        

        if [ -f /boot/grub/grub.cfg ] || [ -f /boot/grub2/grub.cfg ]
        then
           g30s_bootLoaderType="${g30s_bootLoaderType}grub2,"
        fi
        

        efimountinfo=`mount | grep /boot/efi`
        if [ ! -f /boot/grub/menu.lst ] && [ -d /boot/efi ] && [ -f /etc/grub.conf ] && [ -L /etc/grub.conf ] && [ "$efimountinfo" != "" ]
        then
           g30s_bootLoaderType="${g30s_bootLoaderType}egrub,"
        fi
        
        g10s_getOSType
        if [ $(echo "${G10S_CUR_FLAG}" | grep -c -E "(CentOSSeriesEfiBootLoader)") -ne 0 ] || \
            [ $(echo "${g10s_OSVersion}" | grep -c -E "(CentOS7|OL7)") -eq 1 ]
        then   
            if [ "$efimountinfo" != "" ] && [ -f /boot/efi/EFI/redhat/grub.cfg -o -f /boot/efi/EFI/centos/grub.cfg -o -f /boot/efi/EFI/almalinux/grub.cfg ]
            then
                g30s_bootLoaderType="${g30s_bootLoaderType}egrub2,"
            fi

        elif [ `echo "${g10s_OSVersion}" | grep -c -E "(EULEROS2)"` -eq 1 ]
        then
            if [ "$efimountinfo" != "" ] && [ -f /boot/efi/EFI/euleros/grub.cfg ]
            then
                g30s_bootLoaderType=",egrub2,"
            fi
        elif [ $(echo "${g10s_OSVersion}" | grep -c -E "(NFS4U0|NFSSEC)") -eq 1 ]
        then
            if [ "$efimountinfo" != "" ] && [ -f /boot/efi/EFI/NFS/grub.cfg ]
            then
                g30s_bootLoaderType=",egrub2,"
            fi
        elif [ `echo "${g10s_OSVersion}" | grep -c -E "(ISOFT4SP0)"` -eq 1 ]
        then
            if [ "$efimountinfo" != "" ] && [ -f /boot/efi/EFI/isoft/grub.cfg ]
            then
                g30s_bootLoaderType=",egrub2,"
            fi

        elif [ $(echo "${g10s_OSVersion}" | grep -c -E "(KYLIN7SP4|KYLIN7SP5|KYLIN7SP6|KYLIN7SP0|KYLIN7SP0_7U6|KYLIN10_Azalea)") -eq 1 ]
        then
            if [ "$efimountinfo" != "" ] && [ -f /boot/efi/EFI/neokylin/grub.cfg ]
            then
                g30s_bootLoaderType=",egrub2,"
            fi

        elif [ $(echo "${g10s_OSVersion}" | grep -c -E "(KYLIN3SP3|KYLIN10|KYLINSEC3U3_6C)") -eq 1 ]
        then
            if [ "$efimountinfo" != "" ] && [ -f /boot/efi/EFI/kylin/grub.cfg ] 
            then
                g30s_bootLoaderType=",egrub2,"
            fi
        elif [ $(echo "${g10s_OSVersion}" | grep -c -E "(KYLINSEC3U4)") -eq 1 ]
        then
            if [ "$efimountinfo" != "" ] && [ -f /boot/efi/EFI/KylinSecOS/grub.cfg ]
            then
                g30s_bootLoaderType=",egrub2,"
            fi

        elif [ $(echo "${g10s_OSVersion}" | grep -c -E "(OpenEuler20_03)") -eq 1 ]
        then
            if [ "$efimountinfo" != "" ] && [ -f /boot/efi/EFI/openEuler/grub.cfg ]
            then
                g30s_bootLoaderType=",egrub2,"
            fi

        elif [ $(echo "${g10s_OSVersion}" | grep -c -E "(CTyunOS2U0)") -eq 1 ]
        then
            if [ "$efimountinfo" != "" ] && [ -f /boot/efi/EFI/ctyunos/grub.cfg ]
            then
                g30s_bootLoaderType=",egrub2,"
            fi

        elif [ $(echo "${g10s_OSVersion}" | grep -c -E "(RockyLinux8U5)") -eq 1 ]
        then
            if [ "$efimountinfo" != "" ] && [ -f /boot/efi/EFI/rocky/grub.cfg ]
            then
                g30s_bootLoaderType=",egrub2,"
            fi

        elif [ `echo "${g10s_OSVersion}" | grep -c -E "ASIANUX7U3"` -eq 1 ]
        then
            if [ "$efimountinfo" != "" ] && [ -f /boot/efi/EFI/centos/grub.cfg ]
            then
                g30s_bootLoaderType=",egrub2,"
            fi

        elif [ $(echo "${G10S_CUR_FLAG}" | grep -c -E "(SLESSeriesEfiBootLoader)") -ne 0 ] || \
            [ $(echo "${g10s_OSVersion}" | grep -c -E "(SLES12)") -eq 1 ]
        then
            if [ "$efimountinfo" != "" ] && [ -f /boot/efi/EFI/sles/grub.cfg -o -f /boot/efi/EFI/sles12/grub.cfg ] && [ -f /boot/grub2/grub.cfg ]
            then
                g30s_bootLoaderType=",egrub2,"
            fi

        elif [ $(echo "${g10s_OSVersion}" | grep -c -E "(FusionOS22)") -eq 1 ]
        then
            if [ "$efimountinfo" != "" ] && [ -f /boot/efi/EFI/FusionOS/grub.cfg ]
            then
                g30s_bootLoaderType=",egrub2,"
            fi
        fi
        
        print_debug "get boot loader type.[${g30s_bootLoaderType}]" "g30s"
        return 0
    }




    function g30s_getBootLoaderType()
    {
        local iCount
        local OLD_IFS
        local ret
        local i
        
        g30s_bootLoaderType=""
        g10s_getConf "${g10s_ultraPathPackagesInfo}" "g30s_bootLoaderType"
    	if [ "${g10s_confValue}" != "" ]
    	then
    	    g30s_bootLoaderType="${g10s_confValue}"
    	    return 0
    	fi
        	
    	g30s_getBootLoaderTypeOnline
    	if [ `echo "${g30s_bootLoaderType}"|awk -F "," '{print NF}'` -lt 3 ]
    	then
    	    print_error "1009" "not found any usable bootLoader file on your system." "g30s"
    	    g30s_bootLoaderType=""
    	    return 1
    	elif [ `echo "${g30s_bootLoaderType}"|awk -F "," '{print NF}'` -gt 3 ]
    	then

    	    print_warning "1010" "there's more than one bootLoaders in your system." "g30s"
    	    g10s_defaultSelect="1"
    	    unset g10s_singleSelectSets
    	    iCount=$(echo "${g30s_bootLoaderType}"|awk -F "," '{print NF}')
    	    OLD_IFS="${IFS}"
            IFS=","
            bootLoaderType=(${g30s_bootLoaderType})
            IFS="${OLD_IFS}"
    	    for (( i=1; i<${iCount}-1; i=i+1 ))
    	    do
    	        g10s_singleSelectSets=(${g10s_singleSelectSets[@]} "${i}" "${bootLoaderType[${i}]}")
                if [ "${UnattendInstallUltraPathFlag}" = "1" ]
                then
                    print_event "2006"  "<${i}>--${bootLoaderType[${i}]}" "g30s"
                fi
    	    done
            if [ "${UnattendInstallUltraPathFlag}" = "1" ]
            then
                print_event "2005"  "Please repair the system bootloader. Then reinstall UltraPath." "g30s"
                eval "${g10s_exitFun} 1"
            else
                print_singleSelect "1011" "please select your bootLoader type which is using now?" "g30s"
                ret=$?
                g30s_bootLoaderType="${bootLoaderType[${ret}]}"
            fi
            
        fi
        
    	g30s_bootLoaderType=$(echo ${g30s_bootLoaderType})
        g30s_bootLoaderType=${g30s_bootLoaderType#,}
        g30s_bootLoaderType=${g30s_bootLoaderType%,}
        g30s_bootLoaderType=$(echo ${g30s_bootLoaderType})
    	g10s_saveConf "${g10s_ultraPathPackagesInfo}" "g30s_bootLoaderType" "${g30s_bootLoaderType}" 
        return 0
    }
    

    function g30s_checkBootFrom_grub()
    {
        local menLstFile
        local defaultNum
        local lineNum
        local nextNum
        local nextLineNum
        local defaultImage
        local unameret
        local cmpret
        local is_exist
        local ret2
        local ret
        
        if [ "$1" != "" ]
        then
            menLstFile="$1"
        else
       	    menLstFile="/boot/grub/menu.lst"	
        fi
        g10s_checkExist "-f" "${menLstFile}" 2
        

        ret=`grep -E -c "^[[:blank:]]*default[[:blank:]=]+[0-9]+[[:blank:]]*(#.*)?$" "${menLstFile}"`
        if [ ${ret} -eq 0 ]
        then
            print_error "1019" "not found \"default\" item in file.[${menLstFile}]" "g30s"
            eval "${g10s_exitFun} 1"
        elif [ ${ret} -gt 1 ]
        then
            print_error "1020" "there's mutiple \"default\" exist.[${menLstFile}]" "g30s"
            eval "${g10s_exitFun} 1"
        fi
        

        defaultNum=`sed -n "s/^[[:blank:]]*default[[:blank:]=][[:blank:]=]*\([0-9][0-9]*\).*$/\1/p" "${menLstFile}"|sed "s/[[:blank:]]//g"`
        print_debug "defaultNum=${defaultNum}" "g30s"
        if ! [ ${defaultNum} -ge 0 ] 2>/dev/null
        then
            print_error "1013" "get default number failed[$1]" "g30s"
            eval "${g10s_exitFun} 1"
        fi
        
        let "defaultNum=defaultNum+1"
        lineNum=`grep -n "^[[:blank:]]*title[[:blank:]]" "${menLstFile}"|sed -n "${defaultNum}p"|awk -F ":" '{print $1}'`
        print_debug "lineNum=${lineNum}" "g30s"
        if ! [ ${lineNum} -ge 0 ] 2>/dev/null
        then
            print_error "1014" "get line number failed[$1]" "g30s"
            eval "${g10s_exitFun} 1"
        fi
        
        nextNum="${defaultNum}"
        let "nextNum=nextNum+1"
        nextLineNum=`grep -n "^[[:blank:]]*title[[:blank:]]" "${menLstFile}"|sed -n "${nextNum}p"|awk -F ":" '{print $1}'`
        if [ "${nextLineNum}" = "" ]
        then
            nextLineNum=`cat "${menLstFile}"|wc -l`
        else
            let "nextLineNum=nextLineNum-1"
        fi
        print_debug "nextLineNum=${nextLineNum}" "g30s"
        if ! [ ${nextLineNum} -ge ${lineNum} ] 2>/dev/null
        then
            print_error "1015" "get next line number failed[${menLstFile}]" "g30s"
            eval "${g10s_exitFun} 1"
        fi
        

        defaultImage=`sed -n "${lineNum},${nextLineNum}p" "${menLstFile}"`
        print_debug "defaultImage=${defaultImage}" "g30s"
        if [ `echo   "${defaultImage}"|grep -c -E "^[[:blank:]]*(initrd|module)[[:blank:]][[:blank:]]*"` -eq 0 ] \
            || [ `echo   "${defaultImage}"|grep -c -E "^[[:blank:]]*title[[:blank:]]"` -ne 1 ]
        then
            print_error "1016" "defaultImage format error." "g30s"
            eval "${g10s_exitFun} 1"
        fi 
        
        if [ "$2" != "" ]
        then
            unameret="$2"
        else
            unameret=`g10s_curUnamer`
        fi
        
        cmpret="NULL"
        
        g10s_getOSType
        if [ `echo "${g10s_OSVersion}"|grep -c -E "(OL5|CentOS4|CentOS5|ROCKY_4.2.39|ROCKY_4.2.40)"` -eq 1 ]
        then
             is_exist=`echo "${defaultImage}"| grep -E "^[[:blank:]]*(initrd|module)[[:blank:]][[:blank:]]*" | grep -c -w "^[^#]*${unameret}"`
        else    
            is_exist=`echo "${defaultImage}"| grep -c "^[^#]*${unameret}"`
        fi
        
        if [ ${is_exist} -eq 0 ]
        then
            print_debug "try to find /vmlinuz..." "g30s"
            ret=`echo "${defaultImage}"|grep -E -c "(^[^#]*/vmlinuz[[:blank:]#]|^[^#]*/vmlinuz$)"`
            if [ ${ret} -ne 0 ]
            then

                ret2=`ls -l /boot/vmlinuz 2>/dev/null|grep -c "${unameret}"`
                if [ ${ret2} -gt 0 ]
                then
                    cmpret="OK"
                fi
            fi
        else
            cmpret="OK"
        fi
        
        if [ "${cmpret}" != "OK" ] && [ "$2" = "" ]
        then
            print_warning "1017" "the bootloader default item maybe not current kernel.[${unameret}]" "g30s"
            if [ "${UnattendInstallUltraPathFlag}" = "1" ]
            then
                print_event "2005"  " Please check and repair the default bootloader of the system. Then reinstall UltraPath." "g30s"
                eval "${g10s_exitFun} 2"
                
            else
                g10s_singleSelectSets=("1" "continue to install--if bootloader default item is not built for current kernel, your system will reboot failed." \
                                    "2" "exit to install.")
                g10s_defaultSelect="2"
                print_singleSelect "1018" "please choose the action you want to do." "g30s"
                if [ $? -eq 2 ]
                then
                    eval "${g10s_exitFun} 2"
                fi
            fi
            return 0
        fi
        
        if [ "${cmpret}" = "OK" ] && [ "$2" != "" ]
        then
            return 1
        fi
        return 0
    }
     
    
    function g30s_checkDefault_LILO()
    {
        if [ "$1" = "" ]
        then
            print_error "2" "param error." "g30s"
            eval "${g10s_exitFun} 1"
        fi
        local defaultCount
        local cmpret
        local fileName="$1"
        local deft=""
        local sour
        local default_label_num
        local default_imge_num
        local os_uname
        local is_exist
        local ret
        local ret2
        
        defaultCount=`grep -E -c "^[[:blank:]]*default[[:blank:]=]+.*$" "${fileName}"`
        if [ ${defaultCount} -eq 0 ]
        then
            print_error "1021" "not found \"default\" item in file.[${menLstFile}]" "g30s"
            eval "${g10s_exitFun} 1"
        elif [ ${defaultCount} -gt 1 ]
        then
            print_error "1022" "there's mutiple \"default\" exist.[${menLstFile}]" "g30s"
            eval "${g10s_exitFun} 1"
        fi
          
        deft=`cat "${fileName}"|grep -n "^[[:blank:]]*default[[:blank:]]*=..*"|awk -F "=" '{print $2}'`
        if [ -z "${deft}" ]
        then
            deft=`cat "${fileName}"|grep -n "^[[:blank:]]*default[[:blank:]]* ..*"|awk -F " " '{print $2}'`
        fi
        if [ -z "${deft}" ]
        then
            print_error "1023" "get default value failed.[${fileName}]" "g30s"
            eval "${g10s_exitFun} 1"
        fi
        print_debug "${fileName} default=${deft}" "g30s"
        
        deft=$(echo ${deft})
        

        sour=`grep -n "^[[:blank:]]*label[[:blank:]]*=" "${fileName}"`
        g10s_getEqualLines "${sour}" "${deft}" "=" "#" 
        if [ $? -ne 1 ]
        then
            print_error "1024" "there's no default label found or repeat.[${deft},${fileName}]" "g30s"
            eval "${g10s_exitFun} 1"
        fi
        default_label_num=`echo "${g10s_equalLines}"|awk -F ":" '{print $1}'`
        if ! [ ${default_label_num} -ge 0 ] 2>/dev/null
        then
            print_error "1025" "default_label_num is incorrect.[${default_label_num}]" "g30s"
            eval "${g10s_exitFun} 1"
        fi
        print_debug "${fileName} default linenum is ${default_label_num}" "g30s"
        

        default_imge_num=`cat "${fileName}"|grep -n "^[[:blank:]]*image[[:blank:]]*=..*"|awk -F ":" -v col=${default_label_num} \
            '{if($1 <= col) print $1}'|sed -n '$p'`
        if [ -z "${default_imge_num}" ]
        then
            print_error "1026" "not found image in [${fileName}]" "g30s"
            eval "${g10s_exitFun} 1"
        fi
        print_debug "default imagenum is ${default_imge_num}" "g30s"
        
 
        if [ "$2" != "" ]
        then
            os_uname="$2"
        else
            os_uname=`g10s_curUnamer`
        fi
 
        cmpret="NULL"  
        is_exist=`cat "${fileName}" | sed -n "${default_imge_num}p" | grep "${os_uname}" | wc -l`
        if [ ${is_exist} -eq 0 ]
        then
            ret=`sed -n "${default_imge_num}p" "${fileName}" | grep -E "(^[^#]*/vmlinuz[[:blank:]#]|^[^#]*/vmlinuz$)" | wc -l`
            if [ ${ret} -ne 0 ]
            then

                ret2=`ls -l /boot/vmlinuz 2>/dev/null|grep "${os_uname}"|wc -l`
                if [ ${ret2} -gt 0 ]
                then
                    cmpret="OK"
                fi
            fi
        else
            cmpret="OK"
        fi
          
        if [ "${cmpret}" != "OK" ]&& [ "$2" = "" ]
        then
            print_warning "1027" "maybe the bootloader default item is not current kernel.[${unameret}]" "g30s"
            if [ "${UnattendInstallUltraPathFlag}" = "1" ]
            then
                print_event "2005" " Please check and repair the default bootloader of the system. Then reinstall UltraPath." "g30s"
                eval "${g10s_exitFun} 2"        
            else
                g10s_singleSelectSets=("1" "continue install--if bootloader default item is not build for current kernel, your system will reboot failed." \
                                    "2" "exit this install.")
                g10s_defaultSelect="2"
                print_singleSelect "1028" "please choose the action you want to do." "g30s"
                if [ $? -eq 2 ]
                then
                    eval "${g10s_exitFun} 2"
                fi
            fi
            return 0
        fi
        
        if [ "${cmpret}" = "OK" ] && [ "$2" != "" ]
        then
            return 1
        fi

        return 0
    }
    
    function g30s_checkBootFrom_lilo()
    {
        if [ "$1" != "" ]
        then
            g30s_checkDefault_LILO "$1" "$2"
        else
            g30s_checkDefault_LILO "/etc/lilo.conf" "$2"
        fi
        return $?
    }
    
    function g30s_checkBootFrom_elilo()
    {
        if [ "$1" != "" ]
        then
            g30s_checkDefault_LILO "$1" "$2"
        else
            g30s_checkDefault_LILO "/etc/elilo.conf" "$2"
        fi
        return $?
    }
    
    function g30s_checkBootFrom_egrub()
    {
        if [ "$1" != "" ]
        then
            g30s_checkBootFrom_grub "$1" "$2"
        else
            g30s_checkBootFrom_grub "/etc/grub.conf" "$2"
        fi
        return $?
    }
    
    function g30s_checkBootFrom_grub2sub()
    {
        local grubcfgFile
        local grubenvFile
        local itemDefault
        local conutline
        local lineNum
        local nextLineNum
        local defaultImage
        local unameret
        local cmpret
        local is_exist
        local ret2
        local ret
        local tmpGrubcfg=${tmpGrubcfg="${g10s_isspBakPath}/grub2.cfg.bak"} 
        
        if [ "$1" != "" ]
        then
            grubcfgFile="$1"
        else
            grubcfgFile="/boot/grub2/grub.cfg"
        fi
        print_debug "${grubcfgFile}"
        grubenvFile="/boot/grub2/grubenv"
        g10s_checkExist "-f" "${grubcfgFile}" 2
        g10s_checkExist "-f" "${grubenvFile}" 2
        
        g10s_getOSType
        itemDefault=`cat ${grubenvFile} | grep saved_entry | awk -F"=" '{print $2}'`
        if [ "${itemDefault}" = "" ] && [ "${g10s_OSVersion}" = "SLES12SP2" ]
        then
        itemDefault="0"
        fi
        if [ -z "${itemDefault}" ]
        then
            print_error "1019" "not found \"default\" item in file.[${grubenvFile}]" "g30s"
            eval "${g10s_exitFun} 1"
        fi
        
        allIsNum=`expr match "${itemDefault}" '[a-zA-Z]*'`
        if [ ${allIsNum} -ne 0 ]
        then      
            itemDefaultpre=`echo "'${itemDefault}'"`
            lineNum=`grep -E -n "^[[:blank:]]*menuentry[[:blank:]]+" "${grubcfgFile}" | sed -n "/${itemDefaultpre}/p" | awk -F ":" '{print $1}'`
            print_debug "lineNum=${lineNum}" "g30s"
            if ! [ ${lineNum} -ge 0 ] 2>/dev/null
            then
                if [ $(echo "${g10s_OSVersion}" | grep -c -E "(CentOS7|KYLIN3SP3|KYLIN7|EULEROS2|ISOFT4SP0|ASIANUX7U3|KYLIN10|KYLINSEC3U4)") -eq 1 ]
                then
                    allIsNum=0
                    itemDefault=0
                    print_debug "this is OS ${g10s_OSVersion}, default item choose 0."
                else
                    print_error "1014" "not found image in [${grubcfgFile}]" "g30s"
                    eval "${g10s_exitFun} 1"
                fi
            fi
        fi
        
        if [ ${allIsNum} -eq 0 ]
        then
            g10s_cp "${grubcfgFile}" "${tmpGrubcfg}"
            if [ $(echo "${G10S_CUR_FLAG}" | grep -c -E "(CheckBootGrubClearList)") -ne 0 ] || \
                [ $(echo "${g10s_OSVersion}"|grep -c -E "(SLES12)") -eq 1 ]
            then
                menuentrylist=(`cat "${tmpGrubcfg}" | grep -E -n "^menuentry[[:blank:]]+" | awk -F ":" '{print $1}'`)             
                print_debug "get the default item is ${itemDefault}."
                if [ "${itemDefault}" -ge "${#menuentrylist[@]}" ] || [ "${itemDefault}" = "" ] 2>/dev/null
                then
                    print_error "1014" "not found image in [${grubcfgFile}]" "g30s"
                    eval "${g10s_exitFun} 1"
                fi         
                deletstart=${menuentrylist[${itemDefault}]}
                print_debug "begin to delete :${deletstart}" "g30s"
                sed -i "1,${deletstart}d" "${tmpGrubcfg}"
                lineNum=${deletstart}
            else
                n=0
                lineNum=0
                while read line
                do
                    let lineNum=lineNum+1
                    TMP=`echo $line | grep -E "^[[:blank:]]*menuentry[[:blank:]]+"`              
                    if [ "${TMP}" = "" ]
                    then
                        continue
                    fi
                    
                    if [ ${n} -lt ${itemDefault} ]
                    then
                        n=`expr $n + 1`
                        continue
                    else
                        break
                    fi           
                done < ${tmpGrubcfg}
                
                print_debug "lineNum=${lineNum}" "g30s"
                if ! [ ${lineNum} -ge 0 ] 2>/dev/null
                then
                    print_error "1014" "not found image in [${grubcfgFile}]" "g30s"
                    eval "${g10s_exitFun} 1"
                fi
            fi
        fi
        
        if [ -f "${tmpGrubcfg}" ]
        then
            rm -f "${tmpGrubcfg}"
        fi
        let lineNum=lineNum+1
        nextLineNum=$lineNum
        conutline=1
        while read line
        do
            if [ $conutline -le $lineNum ]
            then
                let conutline=conutline+1
                continue
            else
                if [ "$line" = "}" ]
                then
                    break
                fi
                nextLineNum=`expr $nextLineNum + 1`
            fi
        done < ${grubcfgFile}
        let nextLineNum=nextLineNum+2

        if [ "${nextLineNum}" = "" ]
        then
            nextLineNum=`cat "${grubcfgFile}"|wc -l`
        else
            let "nextLineNum=nextLineNum-1"
        fi
        print_debug "nextLineNum=${nextLineNum}" "g30s"
        if ! [ ${nextLineNum} -ge ${lineNum} ] 2>/dev/null
        then
            print_error "1015" "get next line number failed[${grubcfgFile}]" "g30s"
            eval "${g10s_exitFun} 1"
        fi
        

        defaultImage=`sed -n "${lineNum},${nextLineNum}p" "${grubcfgFile}"`
        print_debug "defaultImage=${defaultImage}" "g30s"
        if [ `sed -n "${lineNum},${nextLineNum}p" "${grubcfgFile}" | grep -c -E "^[[:blank:]]*(initrd16|initrd|initrdefi|module)[[:blank:]][[:blank:]]*"` -eq 0 ] 
        then
            print_error "1016" "defaultImage format error." "g30s"
            eval "${g10s_exitFun} 1"
        fi 
        
        if [ "$2" != "" ]
        then
            unameret="$2"
        else
            unameret=`g10s_curUnamer`
        fi
        
        cmpret="NULL"
        is_exist=`echo "${defaultImage}"| grep -c "^[^#]*${unameret}"`
        if [ ${is_exist} -eq 0 ]
        then
            print_debug "try to find /vmlinuz..." "g30s"
            ret=`echo "${defaultImage}"|grep -E -c "(^[^#]*/vmlinuz[[:blank:]#]|^[^#]*/vmlinuz$)"`
            if [ ${ret} -ne 0 ]
            then

                ret2=`ls -l /boot/vmlinuz 2>/dev/null|grep -c "${unameret}"`
                if [ ${ret2} -gt 0 ]
                then
                    cmpret="OK"
                fi
            fi
        else
            cmpret="OK"
        fi
        
        if [ "${cmpret}" != "OK" ] && [ "$2" = "" ]
        then
            print_warning "1017" "the bootloader default item maybe not current kernel.[${unameret}]" "g30s"
            if [ "${UnattendInstallUltraPathFlag}" = "1" ]
            then
                print_event "2005" " Please check and repair the default bootloader of the system. Then reinstall UltraPath." "g30s"
                eval "${g10s_exitFun} 2"        
            else
                g10s_singleSelectSets=("1" "continue to install--if bootloader default item is not built for current kernel, your system will reboot failed." \
                                    "2" "exit to install.")
                g10s_defaultSelect="2"
                print_singleSelect "1018" "please choose the action you want to do." "g30s"
                if [ $? -eq 2 ]
                then
                    eval "${g10s_exitFun} 2"
                fi
            fi
            return 0
        fi
        
        if [ "${cmpret}" = "OK" ] && [ "$2" != "" ]
        then
            return 1
        fi
        return 0
    }

    function g30s_checkBootFrom_grub2sub_byGrubby()
    {
        local itemDefault
        local defaultImage
        local unameret
        local cmpret
        local is_exist

        g10s_getOSType
        itemDefault=`grubby --default-index 2>/dev/null |grep '^[[:digit:]]*$'`

        if [ -z "${itemDefault}" ]
        then
            print_error "1019" "get default-index failed by grubby." "g30s"
            eval "${g10s_exitFun} 1"
        fi

        defaultImage=`grubby --info=${itemDefault} 2>/dev/null`
        if [ -z "${defaultImage}" ]
        then
            print_error "1016" "get defaultImage failed." "g30s"
            eval "${g10s_exitFun} 1"
        fi
        print_debug "defaultImage=${defaultImage}" "g30s"

        if [ `echo ${defaultImage} | grep -c -E "[[:blank:]]*(initrd16|initrd|initrdefi|module)=[[:blank:]]*"` -eq 0 ] 
        then
            print_error "1016" "defaultImage format error." "g30s"
            eval "${g10s_exitFun} 1"
        fi 

        if [ "$1" != "" ]
        then
            unameret="$1"
        else
            unameret=`g10s_curUnamer`
        fi

        cmpret="NULL"
        is_exist=`echo "${defaultImage}"| grep -c "^[^#]*${unameret}"`
        if [ ${is_exist} -ne 0 ]
        then
            cmpret="OK"
        fi

        if [ "${cmpret}" != "OK" ] && [ "$1" = "" ]
        then
            print_warning "1017" "the bootloader default item maybe not current kernel.[${unameret}]" "g30s"
            if [ "${UnattendInstallUltraPathFlag}" = "1" ]
            then
                print_event "2005" " Please check and repair the default bootloader of the system. Then reinstall UltraPath." "g30s"
                eval "${g10s_exitFun} 2"
            else
                g10s_singleSelectSets=("1" "continue to install--if bootloader default item is not built for current kernel, your system will reboot failed." \
                                    "2" "exit to install.")
                g10s_defaultSelect="2"
                print_singleSelect "1018" "please choose the action you want to do." "g30s"
                if [ $? -eq 2 ]
                then
                    eval "${g10s_exitFun} 2"
                fi
            fi
            return 0
        fi
        
        if [ "${cmpret}" = "OK" ] && [ "$1" != "" ]
        then
            return 1
        fi
        return 0
    }

function g30s_checkDefaultItemValidForRocky()
{
    g30s_regExpr="^[[:blank:]]*menuentry[[:blank:]]*"
    g10s_checkExist "-f" "${1}" 2
    
    defaultNum=`sed -n "s/^[[:blank:]]*set[[:blank:]]*default[[:blank:]='\"][[:blank:]='\"]*\([0-9][0-9]*\).*$/\1/p" "$1"|sed "s/[[:blank:]]//g"`
    print_debug "defaultNum=${defaultNum}"
    
    if ! [ ${defaultNum} -ge 0 ] 2>/dev/null
    then
        print_error "1009" "get default number failed[$1]"
        eval "${g10s_exitFun} 1"
    fi
    
    let "defaultNum=defaultNum+1"
    lineNum=`grep -n -E "${g30s_regExpr}" "$1"|sed -n "${defaultNum}p"|awk -F ":" '{print $1}'`
    print_debug "lineNum=${lineNum}"
    
    if ! [ ${lineNum} -ge 0 ] 2>/dev/null
    then
        print_error "1010" "get line number failed[$1]"
        eval "${g10s_exitFun} 1"
    fi
    
    nextNum="${defaultNum}"
    let "nextNum=nextNum+1"
    nextLineNum=`grep -n -E "${g30s_regExpr}" "$1"|sed -n "${nextNum}p"|awk -F ":" '{print $1}'`
    if [ "${nextLineNum}" = "" ]
    then
        nextLineNum=`cat "$1"|wc -l`
    else
        let "nextLineNum=nextLineNum-1"
    fi
    
    defaultImage=`sed -n "${lineNum},${nextLineNum}p" "$1"`
    defaultImage=`echo "${defaultImage}" | grep -v "^[[:blank:]]*#"`

    if [ `echo  "${defaultImage}"|grep -c -E "[[:blank:]][[:blank:]]*linx-no-root[[:blank:]]*"` -eq 0 ]
    then
        return 0
    else
        return 2
    fi
}
    
    function g30s_checkBootFrom_grub2()
    {
        g10s_getOSType
        if [ $(echo "${G10S_CUR_FLAG}" | grep -c -E "(CheckBootGrubByGrubby)") -ne 0 ] || \
           [ $(echo "${g10s_OSVersion}"|grep -c -E "(NFS4U0|NFSSEC)") -eq 1 ] || \
           [ $(echo "${g10s_OSVersion}"|grep -c -w "KYLIN10SP2") -eq 1 ] || \
           [ $(echo "${g10s_OSVersion}"|grep -c -w "KYLIN10SP3") -eq 1 ] || \
           [ $(echo "${g10s_OSVersion}"|grep -c -w "KYLINSEC3U4") -eq 1 ] || \
           [ $(echo "${g10s_OSVersion}"|grep -c -w "RockyLinux8U5") -eq 1 ]
        then
            g30s_checkBootFrom_grub2sub_byGrubby "$2"
            return $?
        elif [ $(echo "${G10S_CUR_FLAG}" | grep -c -E "(CheckBootGrubByMatch)") -ne 0 ] || \
            [ $(echo "${g10s_OSVersion}" | grep -c -E "(CentOS7|OL7|SLES12|KYLIN3SP3|KYLIN7|EULEROS2|ISOFT4SP0|ASIANUX7U3|KYLIN10)") -eq 1 ]
        then
            g30s_checkBootFrom_grub2sub "$1" "$2"
            return $?
        elif [ `echo "${g10s_OSVersion}"|grep -c -E "ROCKY_6.0.42"` -eq 1 ]
        then
            g30s_checkDefaultItemValidForRocky "/boot/grub/grub.cfg"
            ret=$?
            if [ $ret -eq 2 ]
            then
                print_warning "37" "Modify the autostart on boot mode to make sure that the system can be logged in as user root." "g30s"
                eval "${g10s_exitFun} 1"
            fi
        else
            return 0
        fi
        return 0
    }
    
    function g30s_checkBootFrom_egrub2()
    {
        g10s_getOSType
        if [ $(echo "${G10S_CUR_FLAG}" | grep -c -E "(CheckBootGrubWithCfg)") -ne 0 ] || \
           [ $(echo "${g10s_OSVersion}" | grep -c -E "(RockyLinux8U5|NFS4U0|NFSSEC|CentOS7|OL7|EULEROS2|KYLIN7SP5|KYLIN7SP6|ISOFT4SP0|KYLIN7SP4|ASIANUX7U3|KYLIN3SP3|KYLIN7SP0|KYLIN7SP0_7U6|KYLIN10|KYLINSEC3U4)") -eq 1 ]
        then
            if [ -f "/boot/efi/EFI/redhat/grub.cfg" ]
            then
                g30s_checkBootFrom_grub2 "/boot/efi/EFI/redhat/grub.cfg" "$2"
                return $?
            fi
            
            if [ -f "/boot/efi/EFI/centos/grub.cfg" ]
            then
                g30s_checkBootFrom_grub2 "/boot/efi/EFI/centos/grub.cfg" "$2"
                return $?
            fi

            if [ -f "/boot/efi/EFI/almalinux/grub.cfg" ]
            then
                g30s_checkBootFrom_grub2 "/boot/efi/EFI/almalinux/grub.cfg" "$2"
                return $?
            fi
            
            if [ -f "/boot/efi/EFI/euleros/grub.cfg" ]
            then
                g30s_checkBootFrom_grub2 "/boot/efi/EFI/euleros/grub.cfg" "$2"
                return $?
            fi
            
            if [ -f "/boot/efi/EFI/isoft/grub.cfg" ]
            then
                g30s_checkBootFrom_grub2 "/boot/efi/EFI/isoft/grub.cfg" "$2"
                return $?
            fi
            
            if [ -f "/boot/efi/EFI/neokylin/grub.cfg" ]
            then
                g30s_checkBootFrom_grub2 "/boot/efi/EFI/neokylin/grub.cfg" "$2"
                return $?
            fi
            
            if [ -f "/boot/efi/EFI/kylin/grub.cfg" ]
            then
                g30s_checkBootFrom_grub2 "/boot/efi/EFI/kylin/grub.cfg" "$2"
                return $?
            fi

            if [ -f "/boot/efi/EFI/KylinSecOS/grub.cfg" ]
            then
                g30s_checkBootFrom_grub2 "/boot/efi/EFI/KylinSecOS/grub.cfg" "$2"
                return $?
            fi

            if [ -f "/boot/efi/EFI/NFS/grub.cfg" ]
            then
                g30s_checkBootFrom_grub2 "/boot/efi/EFI/NFS/grub.cfg" "$2"
                return $?
            fi

            if [ -f "/boot/efi/EFI/openEuler/grub.cfg" ]
            then
                g30s_checkBootFrom_grub2 "/boot/efi/EFI/openEuler/grub.cfg" "$2"
                return $?
            fi

            if [ -f "/boot/efi/EFI/ctyunos/grub.cfg" ]
            then
                g30s_checkBootFrom_grub2 "/boot/efi/EFI/ctyunos/grub.cfg" "$2"
                return $?
            fi
            
            if [ -f "/boot/efi/EFI/rocky/grub.cfg" ]
            then
                g30s_checkBootFrom_grub2 "/boot/efi/EFI/rocky/grub.cfg" "$2"
                return $?
            fi
            
            if [ -f "/boot/efi/EFI/FusionOS/grub.cfg" ]
            then
                g30s_checkBootFrom_grub2 "/boot/efi/EFI/FusionOS/grub.cfg" "$2"
                return $?
            fi

        elif [ $(echo "${G10S_CUR_FLAG}" | grep -c -E "(CheckBootGrubWithDefault)") -ne 0 ] || \
            [ $(echo "${g10s_OSVersion}"|grep -c -E "(SLES12)") -eq 1 ]
        then
            g30s_checkBootFrom_grub2 "" "$2"
            return $?
        else
            return 0
        fi
    }

else
    print_debug "g30s_systemEnvironment is in this shell." "g30s"
fi

