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

CHECK_PATCH_CONDITION()
{
    return
}

PATCH_START()
{
        return
        BOARD_TYPE="`grep "^Product Name is" /proc/osp/bsp | awk '{print $4}'`"
        PANGEA_LINK=$BOARD_TYPE
        cd /startup_disk/image/boot_osp/
        sudo mount -o remount,rw,async /startup_disk/image/
        if [ -f ./sha256sum_sync ]; then 
            sed -i "/product_versions.${PANGEA_LINK}.conf/d" ./sha256sum_sync
            sed -i "/versions.conf/d" ./sha256sum_sync
            sed -i "/Hi1822_fw.bin/d" ./sha256sum_sync
        else
            OS_echo "[1822fw]there is no sha256sum_sync at boot_osp"
        fi
        BOOT_LINK_a=`ls -l /startup_disk/image | grep -a "boot ->" | awk '{print $11}'`
        if [ $BOOT_LINK_a == "boot_osp_bak" ]; then
            cd /startup_disk/image/boot_osp_bak/
            if [ -f ./sha256sum_sync ]; then 
                sed -i "/product_versions.${PANGEA_LINK}.conf/d" ./sha256sum_sync
                sed -i "/versions.conf/d" ./sha256sum_sync
                sed -i "/Hi1822_fw.bin/d" ./sha256sum_sync
            else
                OS_echo "[1822fw]there is no sha256sum_sync at boot_osp_bak"
            fi
        fi
        sync
        
        return
}

PATCH_END()
{
     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_osp/
        sudo mount -o remount,rw,async /startup_disk/image/
        if [ -f ./sha256sum_sync ]; then 
            sed -i "/product_versions.${PANGEA_LINK}.conf/d" ./sha256sum_sync
            sed -i "/versions.conf/d" ./sha256sum_sync
            sed -i "/ioc_fw.bin/d" ./sha256sum_sync
        else
            OS_echo "[1822fw]there is no sha256sum_sync at end"
        fi
        sync
        
        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
