##################################################################################
#
# FW Version Pattern: xx.BB.CC -- BB must match, CC must be greater or equal
#
##################################################################################
currFWver=$(/etc/version -v)
echo "curr: ${currFWver} new: xx.${newFWver}"
# Split Version AA.BB.CC
major_currFWver=${currFWver%%.*} # until first dot
middle_currFWver=${currFWver%.*}; middle_currFWver=${middle_currFWver#*.} # inbetween
minor_currFWver=${currFWver##*.} # since last dot
echo "debug: curr: ${major_currFWver}.${middle_currFWver}.${minor_currFWver}"
middle_newFWver=${newFWver%.*}; middle_newFWver=${middle_newFWver#*.} # inbetween
minor_newFWver=${newFWver##*.} # since last dot
echo "debug: new: \"XX.${middle_newFWver}.${minor_newFWver}\""
##################################################################################
# skip trailing Zeros for calculation with these values
##################################################################################
major_currFWver=${major_currFWver##0}
middle_currFWver=${middle_currFWver##0}
minor_currFWver=${minor_currFWver##0}
major_newFWver=${major_newFWver##0}
middle_newFWver=${middle_newFWver##0}
minor_newFWver=${minor_newFWver##0}
echo "major_currFWver=$major_currFWver"
echo "middle_currFWver=$middle_currFWver"
echo "minor_currFWver=$minor_currFWver"
echo "middle_newFWver=$middle_newFWver"
echo "minor_newFWver=$minor_newFWver"
##################################################################################
# prevent update
##################################################################################
currFWreject=""
if [ -z "${middle_currFWver}" ] || [ -z "${minor_currFWver}" ] || [ -z "${middle_newFWver}" ] || [ -z "${minor_newFWver}" ] ; then
echo "error: could not resolve Firmwareversion"
currFWreject="y"
fi
if [ "$middle_currFWver" -lt "6" ] || [ "$middle_currFWver" -eq "6" ] && [ "$minor_currFWver" -lt "90" ] ; then
echo "error: reject update: current version '0${middle_currFWver}.${minor_currFWver}' < '06.90'"
currFWreject="y"
fi
# abort update
if [ -n "$currFWreject" ] ; then
echo "set INFO led to off (modul=7, state=1)"
/bin/update_led_off
exit "${INSTALL_FIRMWARE_VERSION}"
fi
##################################################################################
# Downgrade with or w/o factorysettings or normal update ?
##################################################################################
if [ "${force_update}" = "y" ] ; then
echo "Force: Accept Firmware Version: xx.${newFWver} "
echo "Force: Downgrade with factorysettings ..."
/bin/setfactorydefaults
echo "Force: factorysettings done."
else
echo "check Firmware Version: xx.${newFWver}"
##################################################################################
# BB (new) < BB (current) : trigger update interaction
# BB (new) = BB (current) && CC (new) < CC (current) : trigger update interaction
##################################################################################
if [ "$middle_newFWver" -lt "$middle_currFWver" ] ; then
echo "warning: Firmware downgrade detected"
# behaviour for devices which basically are downgradable
if [ "${force_down}" = "y" ] ; then
echo "Force: Downgrade w/o factorysettings ..."
# proceed (ignore downgrade, do not trigger interaction)
else
echo "set INFO led to off (modul=7, state=1)"
/bin/update_led_off
exit "${INSTALL_DOWNGRADE_NEEDED}"
fi
else
echo "DEBUG: $middle_newFWver >= $middle_currFWver"
fi
if [ "$middle_newFWver" -eq "$middle_currFWver" ] ; then
if [ "$minor_newFWver" -lt "$minor_currFWver" ] ; then
# behaviour for devices which basically are downgradable
if [ "${force_down}" = "y" ] ; then
echo "Force: Downgrade w/o factorysettings ..."
# proceed (ignore downgrade, do not trigger interaction)
else
echo "set INFO led to off (modul=7, state=1)"
/bin/update_led_off
exit "${INSTALL_DOWNGRADE_NEEDED}"
fi
else
echo "DEBUG: $minor_newFWver >= $minor_currFWver"
fi
else
echo "DEBUG: $middle_newFWver > $middle_currFWver"
fi
echo "Accept Firmware Version: xx.${newFWver}"
fi
# next: check_files