From 31596dc5aab0fe40b2752df9f8a961ae2eee3e54 Mon Sep 17 00:00:00 2001 From: kwindrem <58538395+kwindrem@users.noreply.github.com> Date: Sun, 8 Aug 2021 23:01:56 -0700 Subject: [PATCH] bug fixes in auto update auto update would hang if some packages in the all packages list were not in stalled. Also added autoupdate status to GuiMods menu --- .DS_Store | Bin 6148 -> 8196 bytes CommonResources | 2 +- packageAutoUpdater | 45 ++++++++++++++++++++++++++++++--------------- setup | 9 +++++---- timeStamp | 2 +- version | 2 +- 6 files changed, 38 insertions(+), 22 deletions(-) diff --git a/.DS_Store b/.DS_Store index 6cc6a1c395cc4288e0f300625e3b7e5ebf564271..2728af85ceabe1d10617c191383e37e5d7db27a0 100644 GIT binary patch delta 512 zcmZoMXmOBWU|?W$DortDU;r^WfEYvza8FDWo2aMA$iFdQH}hr%jz7$c**Q2S7O*h# zPv&8fiZ${8s$yZ#V@PMnWGKnacX3I|$xniq(D0%*;jkmBdBn1{L;LX zVz4>E^$;0OPEHQacmc`kY7-M99R*_}qgow>YD+T<9R))JOXJ#FP7ZNZLtD>;+{&uz zn%cTqU_UT0GD2tuekcv2W&;`Q48;to3`GoOz_3eZNKGkD&Pf6~6{G|qHF+wlDN94w zPs_>YSd}1*FRbd)2nArhWx+*xIr(|%K&_0MCD@c0H%IeqX6BOM1`4=>;&HPe$9Lw* X{34!{{dqVzfUW{XF~jC~o;l0_m9BqL delta 232 zcmZp1XfcprU|?W$DortDU=RQ@Ie-{Mvv5sJ6q~50$jGxXU^g=(&tx6}sn}o>kPL$! zLpnnyLrHGFi%U{YeiB4i!;F>jhaFMnQ}D_cWEch~=jRpx^)N6nAK2V1AkH{>u8;u> z!`zkelP?M>!5AWwxrK!{+X%}uPE0?$n4N<|kQuCpL4X@byMi3MG4VU|WPTY>kkc8M PAl?A^jA3&;&m3j|{3bA6 diff --git a/CommonResources b/CommonResources index ed82036..cce392d 100755 --- a/CommonResources +++ b/CommonResources @@ -545,7 +545,7 @@ endScript () fi # flag verison not installed if [ $scriptAction == 'UNINSTALL' ] ; then - packageVersion="("$packageVersion")" + packageVersion="(not installed) $packageVersion" fi # update version Setting - will fail silently if dbus setting doesn't exist dbus -y com.victronenergy.settings /Settings/GuiMods/PackageVersions/$packageName SetValue "$packageVersion" &> /dev/null diff --git a/packageAutoUpdater b/packageAutoUpdater index 550fdf0..f8d8181 100755 --- a/packageAutoUpdater +++ b/packageAutoUpdater @@ -28,11 +28,9 @@ source "/data/SetupHelper/UpdateResources" # $2 is the dbus path setSetting () { - local newValue=$1 - local dbusPath=$2 - if [ ! -z $newValue ]; then - dbus -y com.victronenergy.settings $dbusPath SetValue $newValue > /dev/null - fi + local newValue="$1" + local dbusPath="$2" + dbus -y com.victronenergy.settings $dbusPath SetValue "$newValue" > /dev/null } #### main code starts here @@ -43,13 +41,15 @@ checkUSB=true lastUpdateTime=0 checkingPackage=false updateSetupHelper=false +checkingMessage='' + # 10 minutes between GitHub checks to minimize network traffic gitHubSlowCheckDelay=600 # 10 seconds for first pass gitHubFastCheckDelay=10 gitHubCheckDelay=0 -skipEndProcessing=false +speedUpLoop=false lastGitHubUpdateSetting=0 @@ -64,7 +64,7 @@ while true ; do i=0 pkgArray=($allPackages) while (( i < ${#pkgArray[@]} )); do - skipEndProcessing=false + speedUpLoop=false doUpdate=false # if no removable media is present allow usbUpdates to occur next time there is # this prevents repeated processing of same files @@ -78,7 +78,7 @@ while true ; do packageDir="/data/$package" setupOptionsDir="$setupOptionsRoot"/$package if [ ! -f "$setupOptionsDir/optionsSet" ]; then - sleep 1 + ((i++)) continue # package has been installed, look for it's archives else @@ -112,12 +112,14 @@ while true ; do # if USB update not pending and auto update enabled, look for GitHub updates if ! $doUpdate && (( $autoUpdateSetting != 0 )); then - # change in update mode, start package scan over - if (( $autoUpdateSetting != $lastGitHubUpdateSetting )); then - # start with first package, but don't break out of the loop + # if speeding up the loop, start package scan over + if (( $autoUpdateSetting >= 2 )) && (( $lastGitHubUpdateSetting <= 1 )); then checkingPackage=false - skipEndProcessing=true + # prevent end processing that changes update mode + speedUpLoop=true lastGitHubUpdateSetting=$autoUpdateSetting + fi + if $speedUpLoop ; then break fi @@ -132,6 +134,8 @@ while true ; do currentTime=$(date '+%s') # wait between GitHub updates to minimize traffic if (( $currentTime >= $lastUpdateTime + $gitHubCheckDelay )) ; then + setSetting "checking $package" /Settings/GuiMods/CheckingPackage + checkingMessage='CHECKING' lastUpdateTime=$currentTime getFromGitHub $package if [ $? -eq 1 ]; then @@ -139,6 +143,11 @@ while true ; do doUpdate=true fi checkingPackage=false + elif (( $autoUpdateSetting != 0 )); then + if [[ $checkingMessage != 'WAIT' ]] ; then + setSetting "waiting to check $package" /Settings/GuiMods/CheckingPackage + checkingMessage='WAIT' + fi fi fi if $doUpdate ; then @@ -156,6 +165,12 @@ while true ; do elif [ ! -z $autoUpdateSetting ] && (( $autoUpdateSetting == 0 )); then rm -rf "$packageDir-$gitHubBranch" fi + if (( $autoUpdateSetting == 0 )); then + if [[ $checkingMessage != 'IDLE' ]] ; then + setSetting "Fast updates: 10 sec/pkg, Normal updates: 10 min/pkg" /Settings/GuiMods/CheckingPackage + checkingMessage='IDLE' + fi + fi fi # end if checkingPackage # current package was checked - move on to the next one # if checking was deferred, stay on this package @@ -163,14 +178,12 @@ while true ; do ((i++)) fi sleep 1 - lastGitHubUpdateSetting=$autoUpdateSetting done # prevent further USB updates until media is removed and reinserted if $updatedFromUsb ; then checkUSB=false fi - # continue execution in packageAutoUpdateCleanup # so that this script and the service can exit cleanly if $updateSetupHelper || $rebootNeeded ; then @@ -185,7 +198,8 @@ while true ; do sleep 10000 fi - if ! $skipEndProcessing ; then + # skip processing if we've brokend out of the loop and starting with first package + if ! $speedUpLoop ; then # single pass if (( $autoUpdateSetting == 3 )) ; then setSetting 0 /Settings/GuiMods/GitHubAutoUpdate @@ -194,4 +208,5 @@ while true ; do setSetting 1 /Settings/GuiMods/GitHubAutoUpdate fi fi + sleep 1 done diff --git a/setup b/setup index 31a2b2c..eb15c0a 100755 --- a/setup +++ b/setup @@ -17,12 +17,14 @@ if [ $scriptAction == 'NONE' ] ; then # if one setting exists, assume they are all there # NOTE: if new settings are added in the future, change test for that one # to avoid creating that new parameter !!!! - autoUpdateSetting=$(dbus-send --system --print-reply=literal --dest=com.victronenergy.settings /Settings/GuiMods/GitHubAutoUpdate\ + + lastSetting=$(dbus-send --system --print-reply=literal --dest=com.victronenergy.settings /Settings/GuiModsCheckingPackage\ com.victronenergy.BusItem.GetValue 2> /dev/null | awk '{print $3}') - if [ -z $autoUpdateSetting ]; then + if [ -z $lastSetting ]; then logMessage "creating SetupHelper Settings" dbus -y com.victronenergy.settings /Settings AddSettings\ - '%[{"path": "/GuiMods/GitHubAutoUpdate", "default":0} ]' > /dev/null + '%[ {"path": "/GuiMods/GitHubAutoUpdate", "default":0},\ + {"path": "/GuiMods/CheckingPackage", "default":""},]' > /dev/null # move setup option flag to dbus setting if [ -f "$setupOptionsDir/autoGitHubUpdate" ]; then setSetting 1 /Settings/GuiMods/GitHubAutoUpdate @@ -30,7 +32,6 @@ if [ $scriptAction == 'NONE' ] ; then else setSetting 0 /Settings/GuiMods/GitHubAutoUpdate fi - fi # display innitial message diff --git a/timeStamp b/timeStamp index 5c46865..25132b0 100644 --- a/timeStamp +++ b/timeStamp @@ -1 +1 @@ -1628380139 +1628488795 diff --git a/version b/version index e70ef1d..b001f9f 100644 --- a/version +++ b/version @@ -1 +1 @@ -v2.3 +v2.4