From d11b614e92501a917077b38b43fa66c114033811 Mon Sep 17 00:00:00 2001 From: cronyx Date: Wed, 3 Aug 2022 14:58:37 +0300 Subject: [PATCH] sysupgrade: check file not found or corrupt --- general/overlay/usr/sbin/sysupgrade | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/general/overlay/usr/sbin/sysupgrade b/general/overlay/usr/sbin/sysupgrade index 0ae5126d..06aa5ac2 100755 --- a/general/overlay/usr/sbin/sysupgrade +++ b/general/overlay/usr/sbin/sysupgrade @@ -1,9 +1,9 @@ #!/bin/sh # -# OpenIPC.org | v.20220727 +# OpenIPC.org | v.20220803 # -scr_version=1.0.1 +scr_version=1.0.2 args=" $@" @@ -116,16 +116,20 @@ self_update() { else echo -e "\nOnline upgrade, checking sysupgrade version..." curl -s -k -L -o /tmp/sysupgrade "https://raw.githubusercontent.com/OpenIPC/firmware/master/general/overlay/usr/sbin/sysupgrade" - dstv=`grep scr_version /tmp/sysupgrade | head -1 | cut -f 2 -d '='` - if ! [ "${scr_version}" = "${dstv}" ]; then - echo "A new version is available, trying to update..." - chmod +x /tmp/sysupgrade - echo -e "Done. Restarting...\n" - exec /tmp/sysupgrade ${args} - exit 1 - else - echo "Ok, version match." - fi + if [ -f /tmp/sysupgrade ] && grep -q "#!/bin/sh" /tmp/sysupgrade; then + dstv=`grep scr_version /tmp/sysupgrade | head -1 | cut -f 2 -d '='` + if ! [ "${scr_version}" = "${dstv}" ]; then + echo "A new version is available, trying to run updated script..." + chmod +x /tmp/sysupgrade + exec /tmp/sysupgrade ${args} + echo -e "Done. Restarting...\n" + exit 1 + else + echo "Ok, version match." + fi + else + echo -e "\nVersion check failed. Possible network connection problem, script is corrupt or not found. Continue with bundled version." + fi fi }