From d11b614e92501a917077b38b43fa66c114033811 Mon Sep 17 00:00:00 2001 From: cronyx Date: Wed, 3 Aug 2022 14:58:37 +0300 Subject: [PATCH 1/2] 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 } From 6b9174c458f8fd47995f85aa44eef450dbc13a28 Mon Sep 17 00:00:00 2001 From: cronyx Date: Wed, 3 Aug 2022 16:59:39 +0300 Subject: [PATCH 2/2] formatting, delete old symlink --- br-ext-chip-hisilicon/package/openhisilicon | 1 - general/overlay/usr/sbin/sysupgrade | 12 ++++++------ 2 files changed, 6 insertions(+), 7 deletions(-) delete mode 120000 br-ext-chip-hisilicon/package/openhisilicon diff --git a/br-ext-chip-hisilicon/package/openhisilicon b/br-ext-chip-hisilicon/package/openhisilicon deleted file mode 120000 index 4d44f0e6..00000000 --- a/br-ext-chip-hisilicon/package/openhisilicon +++ /dev/null @@ -1 +0,0 @@ -../../general/package/openhisilicon \ No newline at end of file diff --git a/general/overlay/usr/sbin/sysupgrade b/general/overlay/usr/sbin/sysupgrade index 06aa5ac2..d45d6982 100755 --- a/general/overlay/usr/sbin/sysupgrade +++ b/general/overlay/usr/sbin/sysupgrade @@ -113,20 +113,20 @@ free_resources() { self_update() { if echo "${args}" | grep "rootfs" || echo "${args}" | grep "kernel" || echo "${args}" | grep -- "-n" > /dev/null 2>&1; then echo -e "\nOffline upgrade or Overlay clean, skip sysupgrade version check." - else + 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" + curl -s -k -L -o /tmp/sysupgrade "https://raw.githubusercontent.com/OpenIPC/firmware/master/general/overlay/usr/sbin/sysupgrade" 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 + 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 + else echo "Ok, version match." - fi + fi else echo -e "\nVersion check failed. Possible network connection problem, script is corrupt or not found. Continue with bundled version." fi