Starting openHAB Permission Denied

I’m very new to both openHAB and linux. I’m trying to install openHAB on a raspberry pi 2 that’s running OSMC. I originally installed manually but ran into issues trying to figure out how to get the service to run on boot. I read that setup is easier with apt-get so I removed the manual installation and installed via apt-get. Now I can’t even get the openHAB runtime to start. I’ve been fighting different errors and I’ve finally got it down to this permissions error. See below. Does anyone have an idea what I might check to resolve this error? It seems like there’s an error accessing my java install folder. If I’m reading the permissions right, I think everyone has at least read and execute on the bin folder:

osmc@osmc:/opt/jdk1.8.0_91$ ls -l
total 20832
drwxrwxr-x 2 uucp 143 4096 Apr 1 04:28 bin

Here’s the error. Any assistance is greatly appreciated.

● openhab.service - Starts and stops the openHAB Home Automation Bus
Loaded: loaded (/usr/lib/systemd/system/openhab.service; disabled)
Active: failed (Result: exit-code) since Fri 2016-07-15 07:50:45 CDT; 53min ago
Docs: http://www.openhab.org
Process: 2478 ExecStart=/usr/share/openhab/bin/openhab.sh -o (code=exited, status=126)
Process: 2426 ExecStartPre=/usr/share/openhab/bin/setpermissions.sh (code=exited, status=0/SUCCESS)
Main PID: 2478 (code=exited, status=126)

Jul 15 07:50:44 osmc setpermissions.sh[2426]: setting owner openhab:openhab recursively for /var/lib/openhab
Jul 15 07:50:44 osmc setpermissions.sh[2426]: setting permissions and owner openhab:openhab recursively for /var/log/openhab
Jul 15 07:50:44 osmc setpermissions.sh[2426]: setting permissions and owner openhab:openhab recursively for /etc/openhab/configurations
Jul 15 07:50:45 osmc setpermissions.sh[2426]: setting permissions and owner openhab:openhab for /usr/share/openhab/webapps/static
Jul 15 07:50:45 osmc setpermissions.sh[2426]: setting permissions and owner openhab:openhab for /etc/openhab/jetty/etc/keystore
Jul 15 07:50:45 osmc setpermissions.sh[2426]: setting permissions and owner openhab:openhab for /etc/openhab/configurations/users.cfg
Jul 15 07:50:45 osmc openhab.sh[2478]: /usr/share/openhab/bin/openhab.sh: 129: /usr/share/openhab/bin/openhab.sh: /opt/jdk1.8.0_91/bin: Permission denied
Jul 15 07:50:45 osmc systemd[1]: openhab.service: main process exited, code=exited, status=126/n/a
Jul 15 07:50:45 osmc systemd[1]: Unit openhab.service entered failed state.
osmc@osmc:~$

Not sure exactly what is going on with this but it wouldn’t be caused by any of the steps you mentioned.

Personally I would just cut my losses and rebuild the SD card from scratch. It doesn’t take all that long to do and you will be back at a known good state.

That fIxed it. I wiped the sd card and started over and now it all works. Thanks for the suggestion.