From 8a67f6585abddd07f73ad9ea5ad5670389ee310a Mon Sep 17 00:00:00 2001 From: kongfl888 Date: Wed, 17 Jun 2020 02:53:50 +0800 Subject: [PATCH] Update script: verify MD5 for file before upgrading. --- scripts/autoupdate-usb.sh | 6 ++++++ scripts/autoupdate.sh | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/scripts/autoupdate-usb.sh b/scripts/autoupdate-usb.sh index 99242e0..d0e12a9 100755 --- a/scripts/autoupdate-usb.sh +++ b/scripts/autoupdate-usb.sh @@ -20,6 +20,12 @@ fi unzip R2S*.zip rm R2S*.zip if [ -f /mnt/mmcblk0p2/artifact/FriendlyWrt*.img.gz ]; then + cd /mnt/mmcblk0p2/artifact/ + if [ `md5sum -c md5sum.txt|grep -c "OK"` -eq 0 ]; then + echo -e '\e[91m固件HASH值匹配失败,脚本退出\e[0m' + exit 1 + fi + cd /mnt/mmcblk0p2 pv /mnt/mmcblk0p2/artifact/FriendlyWrt*.img.gz | gunzip -dc > FriendlyWrt.img echo -e '\e[92m准备解压镜像文件\e[0m' fi diff --git a/scripts/autoupdate.sh b/scripts/autoupdate.sh index d17eb14..5d69528 100644 --- a/scripts/autoupdate.sh +++ b/scripts/autoupdate.sh @@ -18,6 +18,12 @@ fi unzip R2S*.zip rm R2S*.zip if [ -f /mnt/mmcblk0p2/artifact/FriendlyWrt*.img.gz ]; then + cd /mnt/mmcblk0p2/artifact/ + if [ `md5sum -c md5sum.txt|grep -c "OK"` -eq 0 ]; then + echo -e '\e[91m固件HASH值匹配失败,脚本退出\e[0m' + exit 1 + fi + cd /mnt/mmcblk0p2 pv /mnt/mmcblk0p2/artifact/FriendlyWrt*.img.gz | gunzip -dc > FriendlyWrt.img echo -e '\e[92m准备解压镜像文件\e[0m' fi