openhab / openhab-linuxpkg

Repo for Linux packages
Eclipse Public License 2.0
18 stars 33 forks source link

openHAB3 Post installation process fails #184

Closed TBail closed 3 years ago

TBail commented 3 years ago

Hi there,

today i updated to the latest OH3 version 1930 and whil using apt upgrade i got the following error

Vorbereitung zum Entpacken von .../openhab_3.0.0~S1930-1_all.deb ...
Entpacken von openhab (3.0.0~S1930-1) über (3.0.0~S1929-1) ...
openhab (3.0.0~S1930-1) wird eingerichtet ...

[openHAB] Performing post-update tasks for version 3.0.0:
  Replacing: String org.eclipse.smarthome.i18n to org.openhab.i18n in file /var/lib/openhab/config/org/openhab/i18n.config
  Replacing: String org.eclipse.smarthome.persistence to org.openhab.persistence in file /var/lib/openhab/config/org/openhab/persistence.config
  Replacing: String org.eclipse.smarthome.inbox to org.openhab.inbox in file /var/lib/openhab/config/org/openhab/inbox.config
  Replacing: String org.eclipse.smarthome.folder to org.openhab.folder in file /var/lib/openhab/config/org/openhab/folder.config
  Replacing: String org.eclipse.smarthome.threadpool to org.openhab.threadpool in file /var/lib/openhab/config/org/openhab/threadpool.config
  Replacing: String org.eclipse.smarthome.autoupdate to org.openhab.autoupdate in file /var/lib/openhab/config/org/openhab/autoupdate.config
  Replacing: String org.eclipse.smarthome.core to org.openhab.core in file /var/lib/openhab/jsondb/automation_rules.json
  Replacing: String org.eclipse.smarthome to org.openhab.core in file /var/lib/openhab/jsondb/automation_rules.json
  Replacing: String org.eclipse.smarthome.core to org.openhab.core in file /var/lib/openhab/jsondb/org.openhab.core.items.Item.json
  Replacing: String org.eclipse.smarthome to org.openhab.core in file /var/lib/openhab/jsondb/org.openhab.core.items.Item.json
  Replacing: String org.eclipse.smarthome.core to org.openhab.core in file /var/lib/openhab/jsondb/org.openhab.core.thing.link.ItemChannelLink.json
  Replacing: String org.eclipse.smarthome to org.openhab.core in file /var/lib/openhab/jsondb/org.openhab.core.thing.link.ItemChannelLink.json
  Replacing: String org.eclipse.smarthome.core to org.openhab.core in file /var/lib/openhab/jsondb/org.openhab.core.thing.Thing.json
  Replacing: String org.eclipse.smarthome to org.openhab.core in file /var/lib/openhab/jsondb/org.openhab.core.thing.Thing.json

dpkg: Fehler beim Bearbeiten des Paketes openhab (--configure):
 »installiertes openhab-Skript des Paketes post-installation«-Unterprozess gab den Fehlerwert 1 zurück
Trigger für systemd (241-7~deb10u4) werden verarbeitet ...
Fehler traten auf beim Bearbeiten von:
 openhab
E: Sub-process /usr/bin/dpkg returned an error code (1)

Performing a second apt upgrade gave me the following messages

Paketaktualisierung (Upgrade) wird berechnet... Fertig
0 aktualisiert, 0 neu installiert, 0 zu entfernen und 0 nicht aktualisiert.
1 nicht vollständig installiert oder entfernt.
Nach dieser Operation werden 0 B Plattenplatz zusätzlich benutzt.
Möchten Sie fortfahren? [J/n] j
openhab (3.0.0~S1930-1) wird eingerichtet ...

[openHAB] openHAB was not running so will not start after upgrade.
[openHAB] Please use the command:
            sudo /bin/systemctl start openhab.service

The system recognises that something is missing and finished the upgrade without errors.

The system is a virtual machine with Debian 10 on a synology NAS.

BClark09 commented 3 years ago

Hi @TBail, I edited your post to display the formatting correctly.

There have been a couple of reports on this, but there's no indication which line produces an exit code. There's only a few lines that occur after the "post-update tasks", could you use the following command and tell me what the response is?

java -version 2>&1 | awk -F '"' '/version/ {print $2}' | sed -e 's/_.*//g; s/^1\.//g; s/\..*//g; s/-.*//g;'
TBail commented 3 years ago

Output from the command is a simple 11. Here is the full java -version output

openjdk version "11.0.8" 2020-07-14 LTS
OpenJDK Runtime Environment Zulu11.41+23-CA (build 11.0.8+10-LTS)
OpenJDK 64-Bit Server VM Zulu11.41+23-CA (build 11.0.8+10-LTS, mixed mode)
TBail commented 3 years ago

Created today acomplete fresh install and had no errors. Will check that on the next updates.

TBail commented 3 years ago

The first update brought the error again. but the next update i changed some things.

1.) Stopped OH before update 2.) Run openhab-cli clean-cache 3.) Run openhab-cli reset-ownership

No error in Update. Will try tomorrow other/less combinations

TBail commented 3 years ago

Updated today to the latest.

Stopped oh3 before updating

No errors during install/update

TBail commented 3 years ago

Updates to #1999 without stopping openhab an get the error again. Will check that with the next build

TBail commented 3 years ago

And another try. Stopped openhab befor i run the upgrade. With oh3 not running the upgrade works like a charm.

Based on this i assume that there is something wrong with the automatic stop during the upgrade.

mstormi commented 3 years ago

Just hit the same error. Seems the migration is incomplete, while /etc/openhab/* LGTM, /var/lib/openhab only has "etc" and "persistence" so e.g. jsondb is missing (and with it the things and items).

BClark09 commented 3 years ago

This should be fixed from ~S2041 and up. Please let me know if you run into anything else!

jpharvey commented 3 years ago

I have just update to S2042 from 2039 and still got the error

Unpacking openhab (3.0.0~S2042-1) over (3.0.0~S2039-1) ...
Setting up openhab (3.0.0~S2042-1) ...

[openHAB] Performing post-update tasks for version 3.0.0:
  Replacing: String org.eclipse.smarthome.i18n to org.openhab.i18n in file /var/lib/openhab/config/org/openhab/i18n.config
  Replacing: String org.eclipse.smarthome.persistence to org.openhab.persistence in file /var/lib/openhab/config/org/openhab/persistence.config
  Replacing: String org.eclipse.smarthome.audio to org.openhab.audio in file /var/lib/openhab/config/org/openhab/audio.config
  Replacing: String org.eclipse.smarthome.voice to org.openhab.voice in file /var/lib/openhab/config/org/openhab/voice.config
  Replacing: String org.eclipse.smarthome.folder to org.openhab.folder in file /var/lib/openhab/config/org/openhab/folder.config
  Replacing: String org.eclipse.smarthome.threadpool to org.openhab.threadpool in file /var/lib/openhab/config/org/openhab/threadpool.config
  Replacing: String org.eclipse.smarthome.autoupdate to org.openhab.autoupdate in file /var/lib/openhab/config/org/openhab/autoupdate.config
  Replacing: String org.eclipse.smarthome.chart to org.openhab.chart in file /var/lib/openhab/config/org/openhab/chart.config
  Replacing: String org.eclipse.smarthome.core to org.openhab.core in file /var/lib/openhab/jsondb/automation_rules.json
  Replacing: String org.eclipse.smarthome to org.openhab.core in file /var/lib/openhab/jsondb/automation_rules.json
  Replacing: String org.eclipse.smarthome.core to org.openhab.core in file /var/lib/openhab/jsondb/org.openhab.core.config.discovery.DiscoveryResult.json
  Replacing: String org.eclipse.smarthome to org.openhab.core in file /var/lib/openhab/jsondb/org.openhab.core.config.discovery.DiscoveryResult.json
  Replacing: String org.eclipse.smarthome.core to org.openhab.core in file /var/lib/openhab/jsondb/org.openhab.core.items.Item.json
  Replacing: String org.eclipse.smarthome to org.openhab.core in file /var/lib/openhab/jsondb/org.openhab.core.items.Item.json
  Replacing: String org.eclipse.smarthome.core to org.openhab.core in file /var/lib/openhab/jsondb/org.openhab.core.thing.link.ItemChannelLink.json
  Replacing: String org.eclipse.smarthome to org.openhab.core in file /var/lib/openhab/jsondb/org.openhab.core.thing.link.ItemChannelLink.json
  Replacing: String org.eclipse.smarthome.core to org.openhab.core in file /var/lib/openhab/jsondb/org.openhab.core.thing.Thing.json
  Replacing: String org.eclipse.smarthome to org.openhab.core in file /var/lib/openhab/jsondb/org.openhab.core.thing.Thing.json

dpkg: error processing package openhab (--configure):
 installed openhab package post-installation script subprocess returned error exit status 1

This is on a ubuntu system. Let me know if there is anything i can do to try and help identify the problem.

jpharvey commented 3 years ago

@BClark09 I think i have found what is causing the problem. If openhab has been shutdown but was running then in findpid() the pgrep -f 'openhab.*java' will exit with -1 so the script exits with -1. I tested with putting set +e & set -e before and after that and then it doesnt exit at that point. Not sure if that is the best fix but i cant think of a better one.

mstormi commented 3 years ago

I've hit this again on installing S2051. Second run went fine. @BClark09 did you already incorporate @jpharvey's comment ?

jpharvey commented 3 years ago

Having thought about the issue I've seen and when it occurs the post installation work has completed and it is just trying to restart OpenHab so that is the only thing that hasn't happened. Also it wont go through this work if openhab wasn't running so it also matches the analysis from @TBail So at least this is harmless but it is annoying.

BClark09 commented 3 years ago

Thanks for the debugging @jpharvey! You were of course spot on. The previous PR caught other instances of non-zero exits, but I had missed the issue with the findpid function. We should be good on the next snapshot build.