From 6c3fd8a0676a063282e55c74b69516821580940c Mon Sep 17 00:00:00 2001 From: Alfonso Gamboa Date: Fri, 17 Jun 2022 00:06:01 -0700 Subject: [PATCH] remove old version upgrade script, fix rare over-write upgrade-script issue --- README.md | 2 +- SD_ROOT/wz_mini/bin/upgrade-run.sh | 47 +++++--- SD_ROOT/wz_mini/usr/bin/upgrade-run.sh | 161 ------------------------- file.chk | 3 +- 4 files changed, 29 insertions(+), 184 deletions(-) delete mode 100755 SD_ROOT/wz_mini/usr/bin/upgrade-run.sh diff --git a/README.md b/README.md index 8834ade..b84429b 100644 --- a/README.md +++ b/README.md @@ -382,7 +382,7 @@ NOTE: if you are upgrading a V2 camera from a release older than 06-16-22, you m ## Latest Updates * 06-16-22: Simplified the camera model detection method throughout wz_mini. -* 06-16-22: fix scp client bug, allow user modifications to app_init, updated initramfs script, moved upgrade-run to PATH, revised kernel module paths, added ENABLE_RTL8189FS_DRIVER option for v2/v3, updated kernels for v2/v3. ( NOTE: this is a major upgrade, file names for the init scripts have changed, if you are upgrading the V2, do not use the upgrade-run.sh script ) +* 06-16-22: fix scp client bug, allow user modifications to app_init, updated initramfs script, moved upgrade-run to PATH, revised kernel module paths, added ENABLE_RTL8189FS_DRIVER option for v2/v3, updated kernels for v2/v3. ( NOTE: this is a major upgrade, file names for the init scripts have changed, if you are upgrading the V2, do not use the upgrade-run.sh script, please manually update ) * 06-14-22: Updated v4l2rtspserver, fixes to prevent rare low memory situations and RTSP server crashes, fixed intermittant failed RTSP HD stream, script logic updates. * 06-12-22: Added additional audio variables for tuning in libcallback, various bug fixes in wz_user. Added `gather_wz_logs.sh` script for users to share debug logs. * 06-07-22: Added support to tune IMP video and audio options in libcallback. diff --git a/SD_ROOT/wz_mini/bin/upgrade-run.sh b/SD_ROOT/wz_mini/bin/upgrade-run.sh index 662d844..5c4b237 100755 --- a/SD_ROOT/wz_mini/bin/upgrade-run.sh +++ b/SD_ROOT/wz_mini/bin/upgrade-run.sh @@ -1,9 +1,9 @@ #!/bin/sh if [ -L /dev/fd ]; then - echo fd exists + echo "fd exists" > /dev/null else - echo fd does not exist, link + echo "fd does not exist, link" > /dev/null ln -s /proc/self/fd /dev/fd fi @@ -28,29 +28,36 @@ echo "Verify file integrity" cd /opt/Upgrade/wz_mini_hacks-master md5sum -c file.chk -if [ $? -eq 0 ] -then - echo "files OK" - install_upgrade_script +if [ $? -eq 0 ]; then + echo "files OK" + install_upgrade_script else - echo "Failure: archive has corrupted files" - echo "Delete failed upgrade dir" - rm -rf /opt/Upgrade - exit 1 + echo "Failure: archive has corrupted files" + echo "Delete failed upgrade dir" + rm -rf /opt/Upgrade + exit 1 fi } install_upgrade_script() { -echo "Installing latest upgrade-script" +echo "Installing latest upgrade-run from repo" cp /opt/Upgrade/wz_mini_hacks-master/SD_ROOT/wz_mini/bin/upgrade-run.sh /opt/wz_mini/bin/upgrade-run.sh sleep 5 -/opt/wz_mini/bin/upgrade-run.sh backup_begin +echo "Launching latest upgrade-script" +/opt/wz_mini/bin/upgrade-run.sh backup_begin & + +echo "Exit old script" +exit 0 } backup_begin() { +echo "Resume upgrade-run, latest version" + +sleep 5 + echo "Backup user config" cp /opt/wz_mini/wz_mini.conf /opt/Upgrade/preserve/ cp -r /opt/wz_mini/etc/configs /opt/Upgrade/preserve/ @@ -88,7 +95,7 @@ else rmmod audio fi -echo UPGRADE MODE +echo "UPGRADE MODE" if [ -f /opt/wz_mini/tmp/.T20 ]; then echo "Upgrading kernel" @@ -106,12 +113,12 @@ mv /opt/Upgrade/wz_mini_hacks-master/SD_ROOT/factory_t31_ZMC6tiIDQN /opt/factory diff /opt/wz_mini/wz_mini.conf /opt/Upgrade/preserve/wz_mini.conf if [ $(cat /opt/Upgrade/preserve/wz_mini.conf | wc -l) != $(cat /opt/wz_mini/wz_mini.conf | wc -l) ]; then -echo "doesn't match, keep old config" -mv /opt/wz_mini/wz_mini.conf /opt/wz_mini/wz_mini.conf.dist -cp /opt/Upgrade/preserve/wz_mini.conf /opt/wz_mini/ + echo "doesn't match, keep old config" + mv /opt/wz_mini/wz_mini.conf /opt/wz_mini/wz_mini.conf.dist + cp /opt/Upgrade/preserve/wz_mini.conf /opt/wz_mini/ else -echo "configs match" -cp /opt/Upgrade/preserve/wz_mini.conf /opt/wz_mini/ + echo "configs match" + cp /opt/Upgrade/preserve/wz_mini.conf /opt/wz_mini/ fi cp /opt/Upgrade/preserve/ssh/* /opt/wz_mini/etc/ssh/ @@ -124,11 +131,11 @@ reboot } if [[ -e /tmp/dbgflag ]]; then -upgrade_mode_start + upgrade_mode_start else if [ "$1" == "backup_begin" ]; then -backup_begin + 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 diff --git a/SD_ROOT/wz_mini/usr/bin/upgrade-run.sh b/SD_ROOT/wz_mini/usr/bin/upgrade-run.sh deleted file mode 100755 index 662d844..0000000 --- a/SD_ROOT/wz_mini/usr/bin/upgrade-run.sh +++ /dev/null @@ -1,161 +0,0 @@ -#!/bin/sh - -if [ -L /dev/fd ]; then - echo fd exists -else - echo fd does not exist, link - ln -s /proc/self/fd /dev/fd -fi - -LOG_FILE=/opt/upgrade_wz_mini.log -exec > >(busybox tee -a ${LOG_FILE}) 2>&1 - -setup() { - -echo "Create Upgrade directory" -mkdir /opt/Upgrade - -echo "Create backup files directory" -mkdir /opt/Upgrade/preserve - -echo "Download latest master" -wget --no-check-certificate https://github.com/gtxaspec/wz_mini_hacks/archive/refs/heads/master.zip -O /opt/Upgrade/wz_mini.zip; sync - -echo "Extract archive" -unzip /opt/Upgrade/wz_mini.zip -d /opt/Upgrade/ - -echo "Verify file integrity" -cd /opt/Upgrade/wz_mini_hacks-master -md5sum -c file.chk - -if [ $? -eq 0 ] -then - echo "files OK" - install_upgrade_script -else - echo "Failure: archive has corrupted files" - echo "Delete failed upgrade dir" - rm -rf /opt/Upgrade - exit 1 -fi - -} - -install_upgrade_script() { -echo "Installing latest upgrade-script" -cp /opt/Upgrade/wz_mini_hacks-master/SD_ROOT/wz_mini/bin/upgrade-run.sh /opt/wz_mini/bin/upgrade-run.sh - -sleep 5 - -/opt/wz_mini/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/ -cp -r /opt/wz_mini/etc/ssh /opt/Upgrade/preserve/ -cp -r /opt/wz_mini/etc/wireguard /opt/Upgrade/preserve/ -sync - -echo "Rebooting into UPGRADE MODE" -reboot -} - - -upgrade_mode_start() { - -export WZMINI_CFG=/opt/wz_mini/wz_mini.conf - -[ -f $WZMINI_CFG ] && source $WZMINI_CFG - -set -x - -#Set the correct GPIO for the audio driver (T31 only) -if [ -f /opt/wz_mini/tmp/.HL_PAN2 ]; then - GPIO=7 -elif [ -f /opt/wz_mini/tmp/.WYZE_CAKP2JFUS ]; then - GPIO=63 -fi - -if [ -f /opt/wz_mini/tmp/.T20 ]; then - insmod /opt/Upgrade/wz_mini_hacks-master/SD_ROOT/wz_mini/lib/modules/3.10.14/extra/audio.ko - LD_LIBRARY_PATH='/opt/wz_mini/lib' /opt/wz_mini/bin/audioplay_t20 /opt/Upgrade/wz_mini_hacks-master/SD_ROOT/wz_mini/usr/share/audio/upgrade_mode_v2.wav $AUDIO_PROMPT_VOLUME - rmmod audio -else - insmod /opt/Upgrade/wz_mini_hacks-master/SD_ROOT/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__/extra/audio.ko spk_gpio=$GPIO alc_mode=0 mic_gain=0 - /opt/wz_mini/bin/audioplay_t31 /opt/Upgrade/wz_mini_hacks-master/SD_ROOT/wz_mini/usr/share/audio/upgrade_mode.wav $AUDIO_PROMPT_VOLUME - rmmod audio -fi - -echo UPGRADE MODE - -if [ -f /opt/wz_mini/tmp/.T20 ]; then - echo "Upgrading kernel" - flashcp -v /opt/Upgrade/wz_mini_hacks-master/v2_install/v2_kernel.bin /dev/mtd1 -fi - -umount -l /opt/wz_mini/tmp -ls -l /opt/wz_mini/ -rm -rf /opt/wz_mini/* -sync -mv /opt/Upgrade/wz_mini_hacks-master/SD_ROOT/wz_mini/* /opt/wz_mini/ -rm -f /opt/factory_t31_ZMC6tiIDQN -mv /opt/Upgrade/wz_mini_hacks-master/SD_ROOT/factory_t31_ZMC6tiIDQN /opt/factory_t31_ZMC6tiIDQN - -diff /opt/wz_mini/wz_mini.conf /opt/Upgrade/preserve/wz_mini.conf - -if [ $(cat /opt/Upgrade/preserve/wz_mini.conf | wc -l) != $(cat /opt/wz_mini/wz_mini.conf | wc -l) ]; then -echo "doesn't match, keep old config" -mv /opt/wz_mini/wz_mini.conf /opt/wz_mini/wz_mini.conf.dist -cp /opt/Upgrade/preserve/wz_mini.conf /opt/wz_mini/ -else -echo "configs match" -cp /opt/Upgrade/preserve/wz_mini.conf /opt/wz_mini/ -fi - -cp /opt/Upgrade/preserve/ssh/* /opt/wz_mini/etc/ssh/ -cp /opt/Upgrade/preserve/configs/* /opt/wz_mini/etc/configs -cp -r /opt/Upgrade/preserve/wireguard /opt/wz_mini/etc/ -rm -rf /opt/Upgrade -sync -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]) - if [[ -d /opt/Upgrade ]]; then - echo "WARNING: Old Upgrade directory exists" - read -r -p "${1:-Unable to proceed, must DELETE old Upgrade directory, are you sure? [y/N]} " response - case "$response" in - [yY][eE][sS]|[yY]) - rm -rf /opt/Upgrade - sync - setup - ;; - *) - echo "User denied directory removal, exit" - ;; - esac - else - setup - fi - - ;; - *) - echo "User declined system update, exit" - ;; - esac -fi - -fi diff --git a/file.chk b/file.chk index 0dc1a96..0453ff1 100644 --- a/file.chk +++ b/file.chk @@ -49,7 +49,7 @@ a8970288e72c871bff6a4484f1e733d6 SD_ROOT/wz_mini/bin/readelf 41b56bb30f02bce5f5e2598073151e16 SD_ROOT/wz_mini/bin/ffmpeg e37474a12d76cae16336476cba61e8b8 SD_ROOT/wz_mini/bin/neofetch 7fcc716cda1e024dae1045050a135beb SD_ROOT/wz_mini/bin/audioplay_t31 -4fc59ee666cd95f7af99cc75e21e455b SD_ROOT/wz_mini/bin/upgrade-run.sh +1b34a65eae3c4aed0704cc90e59757ce SD_ROOT/wz_mini/bin/upgrade-run.sh e6a6a9dd8ce138686083a3d4303cea40 SD_ROOT/wz_mini/bin/iperf3 0468ffb319707687557353242a518923 SD_ROOT/wz_mini/bin/wg 65510c6c4d0db4b4679fc92d1c617fdd SD_ROOT/wz_mini/bin/rtmp-stream.sh @@ -77,7 +77,6 @@ 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 -4fc59ee666cd95f7af99cc75e21e455b 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