Dpkg: error processing package openhab2

Platform information:

  • Hardware: Raspberry Pi 3B
  • OS: OpenHABian (latest version)
  • openHAB version: 2

Trying to install Samba Cloud when this happens:

[17:36:22] root@HomeAutomationSystem:~# sudo apt-get install samba samba-common-bin
E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem.
[17:37:56] root@HomeAutomationSystem:~# sudo dpkg --configure -a
dpkg: error processing package openhab2 (--configure):
 package is in a very bad inconsistent state; you should
 reinstall it before attempting configuration
Errors were encountered while processing:
 openhab2

Anyone got a solution?
I don’t want to uninstall and reinstall OpenHAB as I have seen on Google as I don’t want to lose my configuration and have to redo it.
Thanks for your time in advance.

Did you try stopping the OH service before making a change?