From 092e4470efe7d311c094b84a87b9d24870499e87 Mon Sep 17 00:00:00 2001 From: Kai Kreuzer Date: Fri, 12 May 2023 18:58:47 +0200 Subject: [PATCH] Call upgrade tool automatically from within the update script (#1532) Signed-off-by: Kai Kreuzer --- distributions/openhab/src/main/resources/bin/update | 10 ++++++++++ .../openhab/src/main/resources/bin/update.ps1 | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/distributions/openhab/src/main/resources/bin/update b/distributions/openhab/src/main/resources/bin/update index e99a1a966..da6e6df70 100755 --- a/distributions/openhab/src/main/resources/bin/update +++ b/distributions/openhab/src/main/resources/bin/update @@ -253,6 +253,7 @@ SkipModifier="$3" ##Run the initialisation functions defined above setup "$SpecifiedVersion" "$SpecifiedDir" + download "$SkipModifier" transferFile="update.lst" @@ -353,6 +354,15 @@ rm -rf "${TempDir:?}" echo "Restoring previous file ownership ($FileOwner:$FileGroup)" chown -R "$FileOwner:$FileGroup" "$WorkingDir" +## Start the upgrade tool +echo "Starting JSON database update..." +export OPENHAB_USERDATA="$OPENHAB_USERDATA" +java -jar "$WorkingDir/runtime/bin/upgradetool.jar" || { + echo "Update tool failed, please check the openHAB website (www.openhab.org) for manual update instructions." >&2 + exit 1 +} +echo "JSON database updated successfully." + echo "" echo "SUCCESS: openHAB updated from $CurrentVersion to $OHVersion" echo "" diff --git a/distributions/openhab/src/main/resources/bin/update.ps1 b/distributions/openhab/src/main/resources/bin/update.ps1 index c6038378c..eb0875e57 100644 --- a/distributions/openhab/src/main/resources/bin/update.ps1 +++ b/distributions/openhab/src/main/resources/bin/update.ps1 @@ -799,6 +799,14 @@ Function Update-openHAB() { return PrintAndThrow "Could not replace the $AddonsFile" $_ } + # Now run the upgrade tool to update the JSON database + Write-Host "Starting JSON database update..." + java -jar "$($PSScriptRoot)\runtime\bin\upgradetool.jar" + if ($LASTEXITCODE -ne 0) { + Write-Error "Update tool failed, please check the openHAB website (www.openhab.org) for manual update instructions." + exit 1 + } + Write-Host "JSON database updated successfully." # Hop for joy - we did it! Write-Host -ForegroundColor Green "openHAB updated to version $OHVersionName!"