#!/bin/bash
bus=7
address=0x7c
offset=0x40
str=$(i2ctransfer -y -a $bus w2@$address $offset 0x00 r1)
version=${str:2:2}
echo "Fan Board CPLD version got from I2C:$version"
if [ "$version" == "" ]; then
    echo "Fan Board CPLD version is null, skip"
else
    mapper wait /xyz/openbmc_project/software/fb_cpld_active
    busctl set-property xyz.openbmc_project.Software.BMC.Updater /xyz/openbmc_project/software/fb_cpld_active xyz.openbmc_project.Software.Version Version s ${version}
    echo "Restored Fan Board CPLD version ${version}"
fi
