George Hung | 85d9f2a | 2020-05-20 17:22:25 +0800 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | # Copyright (c) 2019-present Lenovo |
| 4 | # Copyright (c) 2020 Quanta Computer Inc. |
| 5 | # Licensed under BSD-3, see COPYING.BSD file for details. |
| 6 | |
| 7 | IMAGE_FILE="/tmp/bios-image" |
| 8 | SIG_FILE="/tmp/bmc.sig" |
| 9 | BURN_IMAGE="/tmp/image-bios" |
| 10 | sha256_image="FFFF" |
| 11 | sha256_file="EEEE" |
| 12 | |
| 13 | echo "Verify bios image..." |
| 14 | |
| 15 | if [ -e $IMAGE_FILE ] && [ -e $SIG_FILE ]; |
| 16 | then |
| 17 | sha256_image=`sha256sum "$IMAGE_FILE" | awk '{print $1}'` |
| 18 | sha256_file=`awk '{print $1}' $SIG_FILE` |
| 19 | fi |
| 20 | |
| 21 | if [[ $sha256_image != $sha256_file ]]; |
| 22 | then |
| 23 | echo "bios image verify fail." |
| 24 | rm -f $IMAGE_FILE |
| 25 | echo "Remove bios image" |
| 26 | exit 1 |
| 27 | else |
| 28 | echo "bios image verify ok." |
| 29 | mv $IMAGE_FILE $BURN_IMAGE |
| 30 | rm -f $SIG_FILE |
| 31 | exit 0 |
| 32 | fi |