When you run it from the console you are running it as a specific user (either yourself or root depending on how you run it) which includes an entire configured environment including shell, permissions, environment variables, etc. When it runs as a service the process gets none of that. When you run it as a service properly (i.e. as a non-privileged user) you don’t even have a shell to rely upon.
Which version of Ubuntu are you running? Since 15 the startup system moved from upstart to systemd. The two are very different in how they manage starting service when Linux boots.
I’ve not tried to install or use policyKit before, but I could see it potentially messing everything up if you just installed it without then configuring it to allow the openhab user access to the resources it needs to run openHAB. I recommend installing openHAB and get it working first and then trying policyKit, and then only install that once you understand how to configure it.
The fact that it didn’t work with apt-get makes me thing either you messed something up with systemd previously or policykit is messing things up.
Finally! I installed a new version of OS (Ubuntu 16.04), and followed the steps from the tutorial again. Made the NFS shars on the Synology, mountet them to /mnt/openhab and createt tom symbolic links (for Logs and Persistance)
After copying the raspbian image and apt-upgrade and a reboot the file system was corrupted. But after formating the SD-Card I could copy the raspbian image again without fault. So this was clearly no case of wear-leveling in the SD-Card but a failure OS or Firmware keeping the file system in order.
Some SD-Card work for months, some fail almost immediatly, even from the same brand. So this must have to do with the low-level writing procedure in my opinion. But since I cannot fix it myself and the setup is always in danger of getting lost, I keep on with my workaround of using an usb stick (and placing come directories to /tmpfs as well).
Had similar issue, a couple of times. Usuall it happened when power off the raspberry the not so nice way (power outage etc.)
My solution finally was to put the whole raspian installation on my Synology NAS and even boot via the Raspi from nfs. Since then I had 0 issues. Of course a NAS could often run directly openhab as well, which might also be a good option. In my case it was not, because the NAS is located in the cellar and m zwave signal was very poor from this location. The Raspi was therefore much easier to place in a more central location…
I wish my Raspi 3 would go more than 3 weeks! It now killed my USB thumb drive and I can´t help but suspect something wrong with the Pi itself. Other than that it is totally unusable for homeautomation and data logging (weather and whatnot) in my case
I also experienced corruption of the pi3 sd filesystem: I’ve been running openhab on the raspberry pi 3 for one year and a half and corruption happend two or three times. At first I blamed the SD cards but I noticed that corruption was very likely related to improper shutdown due to power outages.
As I wish to keep a very low power solution relying on the Pi itself, I decided to use a power bank as an UPS (selecting a powerbank that simultaneously supply the Pi and recharges its own lithium batteries).
Moreover I implemented a daily sd image rsync backup towards my synology NAS.
The UPS+backup system is in place since one month and no corruption occured so far, but even if it happens I can restore the previous day image in a few minutes.
Did you put any software on your Pi to manage it? A chap here has written some code which computes battery-time remaining. | can see it being useful to trigger a script to let you know when and if the battery back-up is being utilised.
I’ve bough a 15000mAh powerbank (RAVpower) and the Pi is only connected to the network through ethernet. The powerbank lasts at least 24 hours.
I’ve never experienced power outages that long.
Therefore I’ve not set up any battery monitoring script.
Indeed, I had that too. And then suddenly it stopped. I have suspicion it was because in the beginning I was often working on OpenHab, adding things etc. Whether that is the reason and whether it is the reason in your case I do not know.