From 8ee7a39e1af4f8bbfff5ebea34124c38506d3b0a Mon Sep 17 00:00:00 2001 From: Alfonso Gamboa Date: Sat, 4 Jun 2022 05:08:18 -0700 Subject: [PATCH] make sure we always use latest upgrade script --- SD_ROOT/wz_mini/usr/bin/upgrade-run.sh | 27 +++++++++++++++++++------- file.chk | 2 +- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/SD_ROOT/wz_mini/usr/bin/upgrade-run.sh b/SD_ROOT/wz_mini/usr/bin/upgrade-run.sh index 713acd9..ffa25d8 100755 --- a/SD_ROOT/wz_mini/usr/bin/upgrade-run.sh +++ b/SD_ROOT/wz_mini/usr/bin/upgrade-run.sh @@ -1,10 +1,10 @@ #!/bin/sh if [ -L /dev/fd ]; then -echo fd exists + echo fd exists else -echo fd does not exist, link -ln -s /proc/self/fd /dev/fd + echo fd does not exist, link + ln -s /proc/self/fd /dev/fd fi LOG_FILE=/opt/upgrade_wz_mini.log @@ -31,12 +31,21 @@ md5sum -c file.chk if [ $? -eq 0 ] then echo "files OK" - #exit 0 + install_upgrade_script else echo "Failure: archive has corrupted files" exit 1 fi +} + +install_upgrade_script() { +echo "Installing latest upgrade-script" +cp /opt/Upgrade/wz_mini_hacks-master/SD_ROOT/wz_mini/usr/bin/upgrade-run.sh /opt/wz_mini/usr/bin/upgrade-run.sh +/opt/wz_mini/usr/bin/upgrade-run.sh backup_begin +} + +backup_begin() { echo "Backup user config" cp /opt/wz_mini/wz_mini.conf /opt/Upgrade/preserve/ cp -r /opt/wz_mini/etc/configs /opt/Upgrade/preserve/ @@ -44,9 +53,6 @@ cp -r /opt/wz_mini/etc/ssh /opt/Upgrade/preserve/ cp -r /opt/wz_mini/etc/wireguard /opt/Upgrade/preserve/ sync -echo "Installing latest upgrade-script" -cp /opt/Upgrade/wz_mini_hacks-master/SD_ROOT/wz_mini/usr/bin/upgrade-run.sh /opt/wz_mini/usr/bin/upgrade-run.sh - echo "Rebooting into UPGRADE MODE" reboot } @@ -127,6 +133,11 @@ reboot if [[ -e /tmp/dbgflag ]]; then upgrade_mode_start else + +if [ "$1" == "backup_begin" ]; then +backup_begin +else + read -r -p "${1:-wz_mini, this will download the latest version from github and upgrade your system. Are you sure? [y/N]} " response case "$response" in [yY][eE][sS]|[yY]) @@ -153,3 +164,5 @@ read -r -p "${1:-wz_mini, this will download the latest version from github and ;; esac fi + +fi diff --git a/file.chk b/file.chk index 566272c..fa3fcce 100644 --- a/file.chk +++ b/file.chk @@ -74,7 +74,7 @@ ac9f3a5d097d25d5d972c3d2ad288df9 SD_ROOT/wz_mini/usr/bin/ucamera_v2 cf049b9446094cc8a7e07a33cf91c4a8 SD_ROOT/wz_mini/usr/bin/watch_up.sh b339aee882a5d1c943ad08e4282ec3fd SD_ROOT/wz_mini/usr/bin/iCamera-dbg 20b061689308b2cee7edf3b9b906bca7 SD_ROOT/wz_mini/usr/bin/ucamera -0f127cb9742bcd3fcfd77d5a852bc1c5 SD_ROOT/wz_mini/usr/bin/upgrade-run.sh +ab04957b286c8c21f1532bf1947696bd SD_ROOT/wz_mini/usr/bin/upgrade-run.sh 580b1b6e91e72b4a4fef7b21d8954403 SD_ROOT/wz_mini/usr/bin/getSensorType 4c780f0455481d106d47d89f0ae04ed5 SD_ROOT/wz_mini/lib/uClibc.tar 9afeb088e4cbabbe0b04033b560204d0 SD_ROOT/wz_mini/lib/libimp.so