diff --git a/.DS_Store b/.DS_Store index 89a4afa..9a2d4ec 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/ReadMe b/ReadMe index 1456987..c414a52 100644 --- a/ReadMe +++ b/ReadMe @@ -58,8 +58,6 @@ to install and update packages. packageAutoUpdater handles automatic package updates. -There are two methods and they should NOT be used at the same time: USB and GitHub. - GitHub updates are enabled from the setup menu (g) option. if GuiMods is up to date, auto updates can also be controlled from @@ -77,7 +75,6 @@ Automatic updates can be controlled via the GuiMods menu or options in the Setup Fast checks GitHub for a package once every 10 seconds Once checks GitHub for a package once every 10 minutes, but only once, then updates are turned off Disable disables GitHub updates -Updates from USB/SD media disable Git Hub updates to avoid conflicts If you are experimenting with modificaitons and wish to avoid GitHub updates overriding your work, disable automatic updates. @@ -90,14 +87,16 @@ To use the USB update process: Choose the .tar.gz download link. (Do not download from the Code tab or download the .zip file. These won't work.) Copy the archive files to a USB memory stick. + Do NOT unpack the archive Insert the stick in the Venus device. Regardless the update source (USB or GitHub), -packageAutoUpdater replaces the current copy on the Venus device with the archive contents. +packageAutoUpdater replaces the current copy on the Venus device with the archive contents + but only if the version number of the source is newer than the one that's installed. Then the package's setup script is run to reinstall the modificaitons. No user interaction is needed in this process. -A USB package update disables automatic GitHub updates to avoid conflicts. +You may wish to dispalbe GitHub updates if you are updating from a USB/SD memory stick to avoid conflicts. (GitHub and files on a USB stick could have different versions.) packageAutoUpdater runs in the background (as a service). @@ -105,12 +104,9 @@ packageAutoUpdater runs in the background (as a service). packageInstaller provides the opportunity to install packages for the first time, or reinstall them. For each package, packageInstaller prompts the user to install that package. -Reinstallation is not allowed if automatic updates are enabled. -Those packages are skipped. -The user is prompted to disable automaitc updates while running packageInstaller -before checking for packages. +Packages that are already installed will be skipped if automatic updates are enabled. -Packages can be installed from eithera USB memory stick or from GitHub. +Packages can be installed from either a USB memory stick/SD memory card or from GitHub. After the package is copied to the Venus device it's setup script is run and the user must answer the prompts to complete the instalation. @@ -120,7 +116,7 @@ As with package automatic updates, GitHub is the desired source if your Venus de packageInstaller is called from the SetupHelper setup script by choosing the package (p) option at the main prompt. The packageInstaller is a shell script and can also be run manually: -/data/SetupHelper/manualUpdate +/data/SetupHelper/packageInstaller When a package is updated from GitHub or a USB stick, the currently installed package is moved to a backup directory so that the package can be returned to a previous verison should this be necessary. diff --git a/UpdateResources b/UpdateResources index 49aba2e..43890c8 100755 --- a/UpdateResources +++ b/UpdateResources @@ -52,7 +52,6 @@ getFromUsb () local package=$1 local packageArchive="/media/$dir/$package"-$gitHubBranch.tar.gz local packageDir="/data/$package" - local archiveTimeStamp="" local lastUpdate="" # archive not found on USB stick @@ -113,7 +112,6 @@ getFromGitHub () { local package=$1 local packageDir="/data/$package" - local archiveTimeStamp="" local lastUpdate="" # get the version from local copy of package diff --git a/packageAutoUpdater b/packageAutoUpdater index f8d8181..9e09575 100755 --- a/packageAutoUpdater +++ b/packageAutoUpdater @@ -33,15 +33,54 @@ setSetting () dbus -y com.victronenergy.settings $dbusPath SetValue "$newValue" > /dev/null } +# updates status message on GUI +# $1 is the message identifier (not the actual message + +lastMessage='' +lastPackage='' + +updateStatus () +{ + updateDbus=false + checkPackage=false + if [[ $1 == 'IDLE' ]] ; then + message="Fast updates: 10 sec/pkg, Normal updates: 10 min/pkg" + elif [[ $1 == 'USB_DISABLED' ]] ; then + message="USB/SD updates disabled auto GitHub updates" + elif [[ $1 == 'CHECKING' ]] ; then + message="checking $package" + checkPackage=true + elif [[ $1 == 'WAIT' ]] ; then + message="waiting to check $package" + checkPackage=true + elif [[ $1 == 'USB_CHECK' ]] ; then + message="Checking USB/SD for updates" + else + message="" + fi + if [[ $1 != $lastMessage ]]; then + updateDbus=true + elif $checkPackage && [[ $package != $lastPackage ]]; then + updateDbus=true + fi + # update GUI status message + if $updateDbus ; then + setSetting "$message" /Settings/GuiMods/CheckingPackage + fi + lastMessage=$1 + lastPackage=$package +} + + #### main code starts here logMessage "starting up" -checkUSB=true +usbCheck=false +mediaDetected=false lastUpdateTime=0 checkingPackage=false updateSetupHelper=false -checkingMessage='' # 10 minutes between GitHub checks to minimize network traffic @@ -49,80 +88,91 @@ gitHubSlowCheckDelay=600 # 10 seconds for first pass gitHubFastCheckDelay=10 gitHubCheckDelay=0 -speedUpLoop=false lastGitHubUpdateSetting=0 + # loop forever while true ; do rebootNeeded=false - updatedFromUsb=false - # loop through packages, but don't look at new package until time has expired - # this loop will run every 5 seconds even if waiting to access GitHub again + # loop through packages, but don't look at new package until it's been checked for an update + # this loop will run every second even if waiting to access GitHub again # this permits detection of USB media during the long wait for the next GitHub check - i=0 pkgArray=($allPackages) + i=0 while (( i < ${#pkgArray[@]} )); do - 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 - mediaList=($(ls /media)) - if [ -z $mediaList ] ; then - checkUSB=true - fi - # look for new package + # look for installed package if ! $checkingPackage ; then package=${pkgArray[i]} packageDir="/data/$package" setupOptionsDir="$setupOptionsRoot"/$package if [ ! -f "$setupOptionsDir/optionsSet" ]; then - ((i++)) + (( i++ )) continue - # package has been installed, look for it's archives + # package has been installed, continue else checkingPackage=true fi fi + + doUpdate=false + + # pull Git Hub autoupdate mode from dbus + autoUpdateSetting=$(dbus-send --system --print-reply=literal --dest=com.victronenergy.settings /Settings/GuiMods/GitHubAutoUpdate\ + com.victronenergy.BusItem.GetValue 2> /dev/null | awk '{print $3}') + if [ -z $autoUpdateSetting ]; then + autoUpdateSetting=0 + fi + + # check for USB / SD media + mediaList=($(ls /media)) + # no media + if [ -z $mediaList ] ; then + mediaDetected=false + usbCheck=false + # media first detected, start loop over and enable USB checks + elif ! $mediaDetected ; then + mediaDetected=true + usbCheck=true + updateStatus 'USB_CHECK' + i=0 + continue + fi + + # nothing to do - reset loop and wait + if (( $autoUpdateSetting == 0 )) && ! $usbCheck ; then + i=0 + checkingPackage=false + updateStatus 'IDLE' + sleep 1 + continue + fi + if $checkingPackage ; then - autoUpdateSetting=$(dbus-send --system --print-reply=literal --dest=com.victronenergy.settings /Settings/GuiMods/GitHubAutoUpdate\ - com.victronenergy.BusItem.GetValue 2> /dev/null | awk '{print $3}') - if [ -z $autoUpdateSetting ]; then - autoUpdateSetting=0 - fi - # media found, look for package archives - if $checkUSB && [ ! -z $mediaList ]; then + # USB / SD updates + if $usbCheck ; then for dir in ${mediaList[@]} ; do getFromUsb $package if [ $? -eq 1 ]; then logMessage "found $package on USB" - updatedFromUsb=true doUpdate=true - checkingPackage=false - if [ ! -z $autoUpdateSetting ] && (( $autoUpdateSetting != 0 )); then - logMessage "USB update disables GitHub updates - must be reenabled manually !!" - setSetting 0 /Settings/GuiMods/GitHubAutoUpdate - autoUpdateSetting=0 - fi + updateStatus 'CHECKING' break; fi done - fi - - # if USB update not pending and auto update enabled, look for GitHub updates - if ! $doUpdate && (( $autoUpdateSetting != 0 )); then + # done checking for this package, time to move on + checkingPackage=false + + # Git Hub updates + elif (( $autoUpdateSetting != 0 )); then # if speeding up the loop, start package scan over if (( $autoUpdateSetting >= 2 )) && (( $lastGitHubUpdateSetting <= 1 )); then checkingPackage=false - # prevent end processing that changes update mode - speedUpLoop=true lastGitHubUpdateSetting=$autoUpdateSetting + i=0 + continue fi - if $speedUpLoop ; then - break - fi - # set update delay based on update mode if (( $autoUpdateSetting >= 2 )) ; then @@ -134,8 +184,7 @@ 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' + updateStatus 'CHECKING' lastUpdateTime=$currentTime getFromGitHub $package if [ $? -eq 1 ]; then @@ -144,10 +193,7 @@ while true ; do fi checkingPackage=false elif (( $autoUpdateSetting != 0 )); then - if [[ $checkingMessage != 'WAIT' ]] ; then - setSetting "waiting to check $package" /Settings/GuiMods/CheckingPackage - checkingMessage='WAIT' - fi + updateStatus 'WAIT' fi fi if $doUpdate ; then @@ -161,29 +207,34 @@ while true ; do # update via unattended reinstall only logMessage "updating $package" doUpdate $package + if $usbCheck ; then + sleep 1 + fi fi - elif [ ! -z $autoUpdateSetting ] && (( $autoUpdateSetting == 0 )); then + elif (( $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 + # go to next package if done with this one if ! $checkingPackage ; then - ((i++)) + (( i++ )) + fi + if $usbCheck ; then + usleep 200000 + else + sleep 1 fi - sleep 1 done - # prevent further USB updates until media is removed and reinserted - if $updatedFromUsb ; then - checkUSB=false + # single pass + if (( $autoUpdateSetting == 3 )) ; then + setSetting 0 /Settings/GuiMods/GitHubAutoUpdate + # end of first pass, switch to slow updates + elif (( $autoUpdateSetting == 2 )) ; then + setSetting 1 /Settings/GuiMods/GitHubAutoUpdate fi + usbCheck=false + # continue execution in packageAutoUpdateCleanup # so that this script and the service can exit cleanly if $updateSetupHelper || $rebootNeeded ; then @@ -198,15 +249,5 @@ while true ; do sleep 10000 fi - # 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 - # end of first pass, switch to slow updates - elif (( $autoUpdateSetting == 2 )) ; then - setSetting 1 /Settings/GuiMods/GitHubAutoUpdate - fi - fi sleep 1 done diff --git a/packageInstaller b/packageInstaller index 697d3a1..1bc92cf 100755 --- a/packageInstaller +++ b/packageInstaller @@ -48,26 +48,14 @@ if $updateFromUsb ; then fi # allow reinstallations if auto updates are not enabled -# or if they are disabled here -reinstallOk=false autoUpdateSetting=$(dbus-send --system --print-reply=literal --dest=com.victronenergy.settings /Settings/GuiMods/GitHubAutoUpdate\ com.victronenergy.BusItem.GetValue 2> /dev/null | awk '{print $3}') -if [ $autoUpdateSetting == 1 ]; then +if [ -z $autoUpdateSetting ] || [ $autoUpdateSetting == 0 ]; then reinstallOk=true else - echo "manual package reinstallation may conflict with automatic updates" - echo "automatic must be disabled to manually reinstall packages" - yesNoPrompt "Do you wish to disable automatic updates? (y/n): " - if $yesResponse ; then - logMessage "Disabling automatic package updates" - echo "package reinstallation is now possible" - setSetting 0 /Settings/GuiMods/GitHubAutoUpdate - reinstallOk=true - fi + reinstallOk=false fi - - rebootNeeded=false updateSetupHelper=false for package in $allPackages; do @@ -77,7 +65,7 @@ for package in $allPackages; do # if automatic updates are enabled, skip packages that have alreay been installed if [ -e $packageDir ] && [ -f "$setupOptionsRoot/$package/optionsSet" ]; then if ! $reinstallOk ; then - echo "$package found on but has already been installed - skipping" + echo "$package has already been installed and will be automatically updated - skipping" continue fi installText="reinstall" @@ -85,7 +73,6 @@ for package in $allPackages; do installText="install" fi - if $updateFromUsb ; then for dir in ${mediaList[@]} ; do getFromUsb $package diff --git a/setup b/setup index 2ef68d1..79847e9 100755 --- a/setup +++ b/setup @@ -43,8 +43,7 @@ if [ $scriptAction == 'NONE' ] ; then echo "Prevouslly uninstalled packages can also be installed and configured" echo " as an option from the menu either from GitHub or from a USB stick" echo - echo "If internet access is not available, you can manually update/install from a USB stick" - echo "Note: installing from a USB stick disables automatic GitHub updates" + echo "If internet access is not available, you can manually update/install from a USB stick or SD card" echo if [ -f "$setupOptionsDir/optionsSet" ]; then diff --git a/timeStamp b/timeStamp index 25132b0..b2ee970 100644 --- a/timeStamp +++ b/timeStamp @@ -1 +1 @@ -1628488795 +1628916919 diff --git a/version b/version index 92491a0..62c36de 100644 --- a/version +++ b/version @@ -1 +1 @@ -v2.5 +v2.6