#!/bin/sh
source /OSM/script/os_load_base.sh

#修改点：
# 1 使用逐行替换方式代替覆盖文件（上个版本修改）
# 2 增加备份文件是否成功的判断（上个版本修改）
# 3 增加判断sha256_sync是否存在，灌装环境没有sha256_sync文件，判断无该文件就调过对该文件的处理步骤
# 4 删除内存中1822固件补丁压缩包
# 5 针对扩容场景，将boot_osp中内容也进行了同步
# 6 判断是否处于节点上电，如果属于则不需要单独执行固件升级命令，依靠系统同步升级固件
# 7 保留当前补丁脚本的安装函数，之前补丁脚本的安装均直接回退
# 8 从当前补丁(SPH131)开始，首次备份备份文件后缀名为bak，再次备份后缀名为pre。SPH131之后补丁回退函数保留原则：保留第一个补丁回滚函数和最新补丁的回滚函数，其余补丁回滚函数均return
# 9 增加versions.conf文件的sha256sum重算，并手动执行sha256sum -c sha256sum_sync验证boot下文件是否都经过了重算

#热补丁相关临时文件
UPG_HP_TMP_PATCH_FILE="/tmp/hotpatch_tmp_file"
#获取1822补丁的版本号和升级路径
FW_1822_VER=1.5.8.5.1102  #1822固件版本号
SYS_VERSION_FILE=/OSM/conf/versions.conf
FW_1822_OSM=/OSM/Hi1822_fw.bin
FW_1822_PATH=/startup_disk/image/boot/update_pkg/port/Hi1822_fw.bin  #1822固件路径
FW_1822_MODE=3  #1822固件升级模式

#【重要】版本配套表备份文件，此备份文件为1822接口卡版本号备份，文件命名需要独立备份。
VERSION_bak=/startup_disk/image/boot/versions_bak.conf
VERSION_PRE=/startup_disk/image/boot/versions_pre.conf

#1822固件备份文件
FW_1822_bak=/startup_disk/image/boot/update_pkg/port/Hi1822_fw_bak.bin
FW_1822_PRE=/startup_disk/image/boot/update_pkg/port/Hi1822_fw_pre.bin

#sha256sum备份文件
sha256_sync_bak=/startup_disk/image/boot/sha256sum_sync_bak
sha256_sync_pre=/startup_disk/image/boot/sha256sum_sync_pre

#临时备份配套表
PANGEA_LINK="`grep "^Product Name is" /proc/osp/bsp | awk '{print $4}'`"
pangea_ver_bak=/startup_disk/image/boot/product_versions.${PANGEA_LINK}_bak.conf
pangea_ver_pre=/startup_disk/image/boot/product_versions.${PANGEA_LINK}_pre.conf

PANGEA_FwUpgradeSupportCheck()
{
diagnose --auto << EOF > $UPG_HP_TMP_PATCH_FILE
dpl hotupgradesupportcheck $FW_1822_VER $FW_1822_MODE 
quit
EOF
}
PANGEA_FwUpgradeStart()
{
diagnose --auto << EOF > $UPG_HP_TMP_PATCH_FILE
dpl hotupgradestart $FW_1822_PATH $FW_1822_MODE 
quit
EOF
}
PANGEA_FwUpgradeGetStatus()
{
diagnose --auto << EOF > $UPG_HP_TMP_PATCH_FILE
dpl gethotupgradestatus
quit
EOF
}
PANGEA_FwUpgradeVerCheck()
{
diagnose --auto << EOF > $UPG_HP_TMP_PATCH_FILE
dpl hotupgradefwvercheck $FW_1822_VER
quit
EOF
}
PANGEA_FwUpgradeMmlCmd()
{
    FW_1822_VER=`cat /startup_disk/image/boot/versions.conf | grep "Hi1822_fw.bin" | tail -1 | awk -F "," '{print $2}'`
    PANGEA_FwUpgradeVerCheck
    vercheck=`cat $UPG_HP_TMP_PATCH_FILE | grep "failed."`
    if [ -n "$vercheck" ]; then
        OS_echo "[1822fw]dpl hotupgradevercheck is not matched, upgrade it."
    else
        OS_echo "[1822fw]dpl hotupgradevercheck is matched, return"
        exit 0 #当前版本号匹配，不做升级操作直接返回
    fi
    rm $UPG_HP_TMP_PATCH_FILE
    PANGEA_FwUpgradeSupportCheck
    checkResult=`cat $UPG_HP_TMP_PATCH_FILE | grep "is not supported"`
    if [ -n "$checkResult" ]; then
        OS_echo "$checkResult"
        OS_echo "[1822fw]dpl hotupgradesupportcheck $FW_1822_VER $FW_1822_MODE is failed."
        exit 0 #执行升级检测失败返回0
    fi
    OS_echo "[1822fw]dpl hotupgradesupportcheck $FW_1822_VER $FW_1822_MODE is sucessed."
    rm $UPG_HP_TMP_PATCH_FILE
    PANGEA_FwUpgradeStart
    OS_echo "[1822fw] dpl hotupgradestart $FW_1822_PATH $FW_1822_MODE is sucessed."
    PANGEA_FwUpgradeGetStatus
    getstatus=`cat $UPG_HP_TMP_PATCH_FILE | grep "failed."`
    if [ -n "$getstatus" ]; then
        OS_echo "[1822fw]dpl hotupgradegetstatus is failed."
        exit 1 #执行升级状态检测失败返回1
    fi
    OS_echo "[1822fw]dpl hotupgradegetstatus is sucessed."
    rm $UPG_HP_TMP_PATCH_FILE
    PANGEA_FwUpgradeVerCheck
    vercheck=`cat $UPG_HP_TMP_PATCH_FILE | grep "failed."`
    if [ -n "$vercheck" ]; then
        OS_echo "[1822fw]dpl hotupgradevercheck is failed."
        exit 1 #执行升级完成版本号不匹配返回1
    fi
    rm $UPG_HP_TMP_PATCH_FILE
    OS_echo "[1822fw]dpl hotupgradevercheck is sucessed."    
    return 0
}

CHECK_PATCH_CONDITION()
{
    return
}

PATCH_START()
{
    return
}

PATCH_END()
{
	return
    OS_echo "[1822fw]Patch End, begin to install Hi1822 hotpatch"
    if [ -f /OSM/replace_1822_card_firmware.tar.gz ] ; then 
        OS_echo "[1822fw][product] ------patch replace_1822_card_firmware begain .------"
        cd /OSM/
        tar zxvf replace_1822_card_firmware.tar.gz
        #进入/OSM/conf目录获取当前配置表的固件版本号
        cd /OSM/conf/
        orifwver=`cat ./versions.conf | grep "Hi1822_fw.bin" | tail -1 | awk -F "," '{print $2}'`
        OS_echo "[1822fw]the original fw version is $orifwver, SPH050 version is $FW_1822_VER"
        if [ $orifwver != $FW_1822_VER ]; then
            #修改/OSM/conf中versions.conf文件中的Hi1822fw版本号,采用逐行替换的方式
            fwver=`cat ./versions.conf | grep "Hi1822_fw.bin" | tail -1 | awk -F "," '{print $2}'`
            fwnum=`grep -n -A 1 "HI1822_FW" "versions.conf" | tail -1 | awk -F "-" '{print $1}'`
            sed -i "/Hi1822_fw/ s/$fwver/$FW_1822_VER/" versions.conf
            sed -i "$fwnum s/$fwver/$FW_1822_VER/" versions.conf
        fi

        stafwver=`cat /startup_disk/image/boot/versions.conf | grep "Hi1822_fw.bin" | tail -1 | awk -F "," '{print $2}'`   
        stafwver_1=`cat /startup_disk/image/boot_osp/versions.conf | grep "Hi1822_fw.bin" | tail -1 | awk -F "," '{print $2}'`
        OS_echo "[1822fw]boot 1822fw version $stafwver, boot_osp 1822fw version $stafwver_1"
        BOOT_LINK_a=`ls -l /startup_disk/image | grep -a "boot ->" | awk '{print $11}'` #检查boot指向
        OS_echo "[1822fw]boot dir now is $BOOT_LINK_a."
        boot_osp_dbver=`cat /startup_disk/image/boot_osp/versions.conf | grep "SpcVersion=" | awk -F "=" '{print $2}'`
        OS_echo "[1822fw]boot_osp_dbver is $boot_osp_dbver."
        if [ $stafwver != $FW_1822_VER ]; then
            OS_echo "[1822fw][product] ------cp Hi1822_fw.bin to boot .------"
            cd /startup_disk/image/boot/
            #change disk to read-write
            sudo mount -o remount,rw,async /startup_disk/image/

            #备份1822卡固件文件，增加判断是否备份成功
            cmp $FW_1822_PATH $FW_1822_OSM
            cmp_fw_1822=$?
            if [ $cmp_fw_1822 == 0 ]; then
                OS_echo "[1822fw]cp Hi1822_fw.bin is same"
            else
                cp ./update_pkg/port/Hi1822_fw.bin ./update_pkg/port/Hi1822_fw_tmp.bin
                if [ $? == 0 ]; then
                    if [ -f $FW_1822_bak ]; then
                        mv ./update_pkg/port/Hi1822_fw_tmp.bin ./update_pkg/port/Hi1822_fw_pre.bin
                    else
                        mv ./update_pkg/port/Hi1822_fw_tmp.bin ./update_pkg/port/Hi1822_fw_bak.bin
                    fi
                    OS_echo "[1822fw]cp Hi1822_fw.bin success"
                else
                    OS_echo "[1822fw]cp Hi1822_fw.bin failed"
                    rm -rf ./update_pkg/port/Hi1822_fw_tmp.bin
                    exit 1
                fi
            fi
            #备份sha256文件和version文件，增加判断sha256_sync是否存在，以区别环境
            cp ./versions.conf ./versions_tmp.conf
            if [ $? == 0 ]; then
                if [ -f $VERSION_bak ]; then
                    mv ./versions_tmp.conf ./versions_pre.conf
                else
                    mv ./versions_tmp.conf ./versions_bak.conf
                fi
                OS_echo "[1822fw]cp versions.conf success"
            else
                OS_echo "[1822fw]cp versions.conf failed"
                rm -rf ./versions_tmp.conf
                exit 1
            fi

            if [ -f ./sha256sum_sync ]; then 
                cp ./sha256sum_sync ./sha256sum_sync_tmp
                if [ $? == 0 ]; then
                    if [ -f $sha256_sync_bak ]; then
                        mv ./sha256sum_sync_tmp ./sha256sum_sync_pre
                    else
                        mv ./sha256sum_sync_tmp ./sha256sum_sync_bak
                    fi
                    OS_echo "[1822fw]cp sha256sum_sync success"
                else
                    OS_echo "[1822fw]cp sha256sum_sync failed"
                    rm -rf ./sha256sum_sync_tmp
                    exit 1
                fi
            else
                OS_echo "[1822fw]there is no sha256sum_sync"
            fi
            sync
            #替换硬盘目录下1822卡固件文件和version文件中1822固件版本号
            fwver_boot=`cat ./versions.conf | grep "Hi1822_fw.bin" | tail -1 | awk -F "," '{print $2}'`
            fwnum_boot=`grep -n -A 1 "HI1822_FW" "versions.conf" | tail -1 | awk -F "-" '{print $1}'`
            sed -i "/Hi1822_fw/ s/$fwver_boot/$FW_1822_VER/" versions.conf
            sed -i "$fwnum_boot s/$fwver_boot/$FW_1822_VER/" versions.conf
            cp /OSM/Hi1822_fw.bin ./update_pkg/port/Hi1822_fw_now.bin
            if [ $? == 0 ]; then
                mv ./update_pkg/port/Hi1822_fw_now.bin ./update_pkg/port/Hi1822_fw.bin
                OS_echo "[1822fw]cp Hi1822_fw.bin success"
            else
                OS_echo "[1822fw]cp Hi1822_fw.bin failed"
                rm -rf ./update_pkg/port/Hi1822_fw_now.bin
                exit 1
            fi

            BOARD_TYPE="`grep "^Product Name is" /proc/osp/bsp | awk '{print $4}'`"
            PANGEA_LINK=$BOARD_TYPE
            if [ -f ./product_versions.${PANGEA_LINK}.conf ]; then
                profwver=`cat /startup_disk/image/boot/product_versions.${PANGEA_LINK}.conf | grep "Hi1822_fw.bin" | tail -1 | awk -F "," '{print $2}'`
                if [ $profwver != $FW_1822_VER ]; then
                    cp ./product_versions.${PANGEA_LINK}.conf ./product_versions.${PANGEA_LINK}_tmp.conf
                    if [ $? == 0 ]; then
                        if [ -f $pangea_ver_bak ]; then
                            mv ./product_versions.${PANGEA_LINK}_tmp.conf ./product_versions.${PANGEA_LINK}_pre.conf
                        else
                            mv ./product_versions.${PANGEA_LINK}_tmp.conf ./product_versions.${PANGEA_LINK}_bak.conf
                        fi
                        OS_echo "[1822fw]cp product_versions_bak\pre success"
                    else
                        OS_echo "[1822fw]cp product_versions_bak\pre failed"
                        rm -rf ./product_versions.${PANGEA_LINK}_tmp.conf
                        exit 1
                    fi
                    prover=`cat ./product_versions.${PANGEA_LINK}.conf | grep "Hi1822_fw.bin" | tail -1 | awk -F "," '{print $2}'`
                    pronum=`grep -n -A 1 "HI1822_FW" "product_versions.${PANGEA_LINK}.conf" | tail -1 | awk -F "-" '{print $1}'`
                    sed -i "/Hi1822_fw/ s/$prover/$FW_1822_VER/" product_versions.${PANGEA_LINK}.conf
                    sed -i "$pronum s/$prover/$FW_1822_VER/" product_versions.${PANGEA_LINK}.conf
                else
                    OS_echo "[1822fw]the fw in product_versions.${PANGEA_LINK}.conf is $profwver"
                fi
            else
                OS_echo "[1822fw]the pangea_link is ${PANGEA_LINK}"
                OS_echo "[1822fw]product_versions.${PANGEA_LINK}.conf is not exist"
            fi

            #都要计算 特有问题 区分下路径
            if [ -f ./sha256sum_sync ]; then 
                local_sum=`sha256sum ./product_versions.${PANGEA_LINK}.conf`
                sed -i "/product_versions.${PANGEA_LINK}.conf/c$local_sum" ./sha256sum_sync
                local_sum=`sha256sum ./versions.conf`
                sed -i "/versions.conf/c$local_sum" ./sha256sum_sync
                local_sum=`sha256sum ./update_pkg/port/Hi1822_fw.bin`
                OS_echo "[1822fw] sha256sum is $local_sum"
                sed -i "/Hi1822_fw.bin/c$local_sum" ./sha256sum_sync
            else
                OS_echo "[1822fw]there is no sha256sum_sync"
            fi
            sync
            OS_echo "[1822fw][product] ------patch replace_1822_card_firmware end .------"
        fi
        
        #针对扩容场景，将boot_osp中内容也同步了。
        if [ $BOOT_LINK_a == "boot_osp_bak" ]; then
            boot_osp_bak_dbver=`cat /startup_disk/image/boot_osp_bak/versions.conf | grep "SpcVersion=" | awk -F "=" '{print $2}'`
            OS_echo "[1822fw]boot_osp_bak_dbver is $boot_osp_bak_dbver."
            if [ $boot_osp_dbver == $boot_osp_bak_dbver ]; then
                cd /startup_disk/image/boot_osp/
                if [ -f versions.conf ] ; then 
                    fwver_osp=`cat ./versions.conf | grep "Hi1822_fw.bin" | tail -1 | awk -F "," '{print $2}'`
                    fwnum_osp=`grep -n -A 1 "HI1822_FW" "versions.conf" | tail -1 | awk -F "-" '{print $1}'`
                    sed -i "/Hi1822_fw/ s/$fwver_osp/$FW_1822_VER/" versions.conf 
                    sed -i "$fwnum_osp s/$fwver_osp/$FW_1822_VER/" versions.conf
                    OS_echo "[1822fw]change startup_disk versions.conf success"
                fi
                cp /OSM/Hi1822_fw.bin /startup_disk/image/boot_osp/update_pkg/port/Hi1822_fw_tmp.bin
                if [ $? == 0 ]; then
                    mv /startup_disk/image/boot_osp/update_pkg/port/Hi1822_fw_tmp.bin /startup_disk/image/boot_osp/update_pkg/port/Hi1822_fw.bin
                    OS_echo "[1822fw]cp startup_disk Hi1822_fw.bin success"
                else
                    OS_echo "[1822fw]cp startup_disk Hi1822_fw.bin failed"
                    rm -rf /startup_disk/image/boot_osp/update_pkg/port/Hi1822_fw_tmp.bin
                    exit 1
                fi
                if [ -f ./sha256sum_sync ]; then 
                    local_sum=`sha256sum ./product_versions.${PANGEA_LINK}.conf`
                    sed -i "/product_versions.${PANGEA_LINK}.conf/c$local_sum" ./sha256sum_sync
                    local_sum=`sha256sum ./versions.conf`
                    sed -i "/versions.conf/c$local_sum" ./sha256sum_sync
                    local_sum=`sha256sum ./update_pkg/port/Hi1822_fw.bin`
                    OS_echo "[1822fw] sha256sum is $local_sum"
                    sed -i "/Hi1822_fw.bin/c$local_sum" ./sha256sum_sync
                else
                    OS_echo "[1822fw]there is no sha256sum_sync in boot_osp_bak"
                fi
            fi
        fi

        #判断是否处于节点上电，如果属于则不需要单独执行固件升级命令，依靠系统同步升级固件
        hifc_sdk=`lsmod | awk '{print $1}' | grep hifc_sdk | wc -l`
        unfcommom=`lsmod | awk '{print $1}' | grep unfcommom | wc -l`

        if [[ $unfcommom -lt 1 && $hifc_sdk -lt 1 ]] ;then
            OS_echo "[1822_hot_patch] system is during power on, return."
            return
        fi

        #执行1822固件升级命令
        PANGEA_FwUpgradeMmlCmd

        #删除内存中1822固件补丁压缩包
        rm -rf /OSM/replace_1822_card_firmware.tar.gz
        rm -rf /OSM/Hi1822_fw.bin
        
    else
        OS_echo "[1822fw]can not find replace_1822_card_firmware.tar.gz"            
    fi

    return
}

PATCH_ROLLBACK()
{
	return
    BOARD_TYPE="`grep "^Product Name is" /proc/osp/bsp | awk '{print $4}'`"
    PANGEA_LINK=$BOARD_TYPE
    #回退版本配套表
    cd /startup_disk/image/boot/
    
    #change disk to read-write
    sudo mount -o remount,rw,async /startup_disk/image/

    if [ -f versions_pre.conf ]; then
        fwbakver=`cat ./versions_pre.conf | grep "Hi1822_fw.bin" | tail -1 | awk -F "," '{print $2}'`
        prover_rol=`cat ./versions.conf | grep "Hi1822_fw.bin" | tail -1 | awk -F "," '{print $2}'`
        pronum_rol=`grep -n -A 1 "HI1822_FW" "versions.conf" | tail -1 | awk -F "-" '{print $1}'`
        sed -i "/Hi1822_fw/ s/$prover_rol/$fwbakver/" versions.conf
        sed -i "$pronum_rol s/$prover_rol/$fwbakver/" versions.conf
        cd /OSM/conf/
        fwver_conf=`cat ./versions.conf | grep "Hi1822_fw.bin" | tail -1 | awk -F "," '{print $2}'`
        fwnum_conf=`grep -n -A 1 "HI1822_FW" "versions.conf" | tail -1 | awk -F "-" '{print $1}'`
        sed -i "/Hi1822_fw/ s/$fwver_conf/$fwbakver/" versions.conf 
        sed -i "$fwnum_conf s/$fwver_conf/$fwbakver/" versions.conf 
        sync
        cd /startup_disk/image/boot/
        rm -rf versions_pre.conf
    elif [ -f versions_bak.conf ]; then
        fwbakver=`cat ./versions_bak.conf | grep "Hi1822_fw.bin" | tail -1 | awk -F "," '{print $2}'`
        prover_rol=`cat ./versions.conf | grep "Hi1822_fw.bin" | tail -1 | awk -F "," '{print $2}'`
        pronum_rol=`grep -n -A 1 "HI1822_FW" "versions.conf" | tail -1 | awk -F "-" '{print $1}'`
        sed -i "/Hi1822_fw/ s/$prover_rol/$fwbakver/" versions.conf
        sed -i "$pronum_rol s/$prover_rol/$fwbakver/" versions.conf
        cd /OSM/conf/
        fwver_conf=`cat ./versions.conf | grep "Hi1822_fw.bin" | tail -1 | awk -F "," '{print $2}'`
        fwnum_conf=`grep -n -A 1 "HI1822_FW" "versions.conf" | tail -1 | awk -F "-" '{print $1}'`
        sed -i "/Hi1822_fw/ s/$fwver_conf/$fwbakver/" versions.conf 
        sed -i "$fwnum_conf s/$fwver_conf/$fwbakver/" versions.conf 
        sync
        cd /startup_disk/image/boot/
        rm -rf versions_bak.conf
    else
        OS_echo "[1822fw]There is no versions_pre/versions_bak.conf in /startup_disk/image/boot/"
    fi
    sync

    cd /startup_disk/image/boot/
    #回退固件
    if [ -f ./update_pkg/port/Hi1822_fw_pre.bin ]; then
        mv ./update_pkg/port/Hi1822_fw_pre.bin ./update_pkg/port/Hi1822_fw.bin
    elif [ -f ./update_pkg/port/Hi1822_fw_bak.bin ]; then 
        mv ./update_pkg/port/Hi1822_fw_bak.bin ./update_pkg/port/Hi1822_fw.bin
    else
        OS_echo "[1822fw]There is no Hi1822_fw_pre\bak.bin "
    fi
    if [ -f product_versions.${PANGEA_LINK}_pre.conf ]; then
        fwbakprover=`cat ./product_versions.${PANGEA_LINK}_pre.conf | grep "Hi1822_fw.bin" | tail -1 | awk -F "," '{print $2}'`
        prover_rpro=`cat ./product_versions.${PANGEA_LINK}.conf | grep "Hi1822_fw.bin" | tail -1 | awk -F "," '{print $2}'`
        pronum_rpro=`grep -n -A 1 "HI1822_FW" "product_versions.${PANGEA_LINK}.conf" | tail -1 | awk -F "-" '{print $1}'`
        sed -i "/Hi1822_fw/ s/$prover_rpro/$fwbakprover/" product_versions.${PANGEA_LINK}.conf
        sed -i "$pronum_rpro s/$prover_rpro/$fwbakprover/" product_versions.${PANGEA_LINK}.conf
        rm -rf product_versions.${PANGEA_LINK}_pre.conf
    elif [ -f product_versions.${PANGEA_LINK}_bak.conf ]; then
        fwbakprover=`cat ./product_versions.${PANGEA_LINK}_bak.conf | grep "Hi1822_fw.bin" | tail -1 | awk -F "," '{print $2}'`
        prover_rpro=`cat ./product_versions.${PANGEA_LINK}.conf | grep "Hi1822_fw.bin" | tail -1 | awk -F "," '{print $2}'`
        pronum_rpro=`grep -n -A 1 "HI1822_FW" "product_versions.${PANGEA_LINK}.conf" | tail -1 | awk -F "-" '{print $1}'`
        sed -i "/Hi1822_fw/ s/$prover_rpro/$fwbakprover/" product_versions.${PANGEA_LINK}.conf
        sed -i "$pronum_rpro s/$prover_rpro/$fwbakprover/" product_versions.${PANGEA_LINK}.conf
        rm -rf product_versions.${PANGEA_LINK}_bak.conf
    else
        OS_echo "[1822fw]There is no product_versions.${PANGEA_LINK}_pre\bak.conf in /startup_disk/image/boot_osp/"
    fi
    
    #都要计算 特有问题 区分下路径
    if [ -f ./sha256sum_sync ]; then 
        local_sum=`sha256sum ./product_versions.${PANGEA_LINK}.conf`
        sed -i "/product_versions.${PANGEA_LINK}.conf/c$local_sum" ./sha256sum_sync
        local_sum=`sha256sum ./versions.conf`
        sed -i "/versions.conf/c$local_sum" ./sha256sum_sync
        local_sum=`sha256sum ./update_pkg/port/Hi1822_fw.bin`
        sed -i "/Hi1822_fw.bin/c$local_sum" ./sha256sum_sync
        sync
        rm -rf ./sha256sum_sync_pre
        rm -rf ./sha256sum_sync_bak
    else
        OS_echo "[1822fw]there is no sha256sum_sync"
    fi

    sync
    #执行1822固件升级命令
    PANGEA_FwUpgradeMmlCmd

    #删除内存中1822固件补丁压缩包
    rm -rf /OSM/replace_1822_card_firmware.tar.gz
    rm -rf /OSM/Hi1822_fw.bin
        
    return
}

PATCH_ROLLEND()
{
return
}

L_CMD=$1
case $L_CMD in
    "start") PATCH_START
               ;;
    "end") PATCH_END
               ;;
    "rollstart") PATCH_ROLLBACK
    CHECK_PATCH_CONDITION
               ;;
    "rollend") PATCH_ROLLEND
               ;;
    *)
         OS_echo "unsupported option."
esac
exit 0
