diff --git a/base-files/iop-files/lib/upgrade/iopsys.sh b/base-files/iop-files/lib/upgrade/iopsys.sh index be79cfc66bb114a3e15debd1a623569165e223f4..d8fc5580cbce4fd3a5c861018ca3f8e052d68a38 100644 --- a/base-files/iop-files/lib/upgrade/iopsys.sh +++ b/base-files/iop-files/lib/upgrade/iopsys.sh @@ -296,7 +296,41 @@ check_sig() { return 1 } +#if user upg by command line sysupgrade, so need to check image in usb disk + +image_in_usb() +{ + local from=$1 + local file_name=$(basename $from) + local file_path + file_path="$(mount -t vfat | awk '{print $3}')" + if [ -z "$file_path" ];then + echo 0 + else + find /mnt/ -name "$file_name" | grep -q mnt && echo 1 || echo 0 + fi +} + + +do_usb_image_op(){ + case "$1" in + save) + #check if the file exist in the usb disk + [ "$(image_in_usb $2)" == "1" ] && cp -f $2 $2.bak + ;; + restore) + if [ -f $2.bak ] ;then + mv $2.bak $2 + fi + ;; + clean) + if [ -f $2.bak ] ;then + rm -f $2.bak + fi + ;; + esac +} #-------------------------------------------------------------- # Verify an Iopsys image is good for writing @@ -326,6 +360,8 @@ iopsys_check_image() { ;; esac + do_usb_image_op "save" $from + [ "$(check_crc $from)" == "CRC_OK" ] || { echo "CRC check failed" return 1 @@ -444,7 +480,8 @@ iopsys_upgrade() { fi # Product specific low level write to flash - target_upgrade $from || return + target_upgrade $from || ( do_usb_image_op "clean" $from ; return ) + do_usb_image_op "restore" $from }