openhab / openhab-distro

The binary distribution of openHAB
https://www.openhab.org/
Eclipse Public License 2.0
1.3k stars 393 forks source link

install-service does not work on Mac OS X 10.11 (El Capitan) #238

Open rrgeorge opened 8 years ago

rrgeorge commented 8 years ago

Running install-service on Mac OS X 10.11 does not function properly, because the variable JAVA_HOME is set to null in the generated runtime/karaf/etc/openHAB-wrapper.conf. JAVA_HOME should be derived from running the command /usr/libexec/java_home when generating the openHAB-wrapper.conf file from install-service

kgoderis commented 8 years ago

I get the following output when issuing the command below

openhab> openhab:install-service 

Starting openHAB system service installation...

Creating file: /Library/openHAB2/openhab2-karaf/runtime/karaf/bin/openHAB-wrapper
Creating file: /Library/openHAB2/openhab2-karaf/runtime/karaf/bin/openHAB-service

And nothing more. Is something else expected to happen?

kaikreuzer commented 8 years ago

@kgoderis: Just tried it and I have

openhab> openhab:install-service 

Starting openHAB system service installation...

Creating file: /Applications/openhab/runtime/karaf/bin/openHAB-wrapper
Creating file: /Applications/openhab/runtime/karaf/bin/openHAB-service
Creating file: /Applications/openhab/runtime/karaf/etc/openHAB-wrapper.conf
Creating file: /Applications/openhab/runtime/karaf/bin/org.apache.karaf.openHAB.plist
Creating missing directory: /Applications/openhab/runtime/karaf/lib/wrapper
Creating file: /Applications/openhab/runtime/karaf/lib/wrapper/libwrapper.jnilib
Creating file: /Applications/openhab/runtime/karaf/lib/wrapper/karaf-wrapper.jar
Creating file: /Applications/openhab/runtime/karaf/lib/wrapper/karaf-wrapper-main.jar

Mac OS X system detected:

To configure openHAB as a user service execute the following file move:
> mv /Applications/openhab/runtime/karaf/bin/openHAB.plist ~/Library/LaunchAgents/

To configure openHAB as a system service execute the following file move and authorisation changes:
> sudo mv /Applications/openhab/runtime/karaf/bin/openHAB.plist /Library/LaunchDaemons/
> sudo chown root:wheel /Library/LaunchDaemons/openHAB.plist
> sudo chmod u=rw,g=r,o=r /Library/LaunchDaemons/openHAB.plist

To test your service: 
> launchctl load ~/Library/LaunchAgents/openHAB.plist
> launchctl start openHAB
> launchctl stop openHAB

After restart of your session or system you can use the launchctl command to start and stop your service

For removing the service call:
> launchctl remove openHAB

openhab> 

@dvanherbergen As you did the integration, any chance that you could have a look at fixing @rrgeorge's problem?

kgoderis commented 8 years ago

The problem is due to the non responsive karaf console.

Sent from my iPhone

On 01 Jul 2016, at 17:16, Kai Kreuzer notifications@github.com wrote:

@kgoderis: Just tried it and I have

openhab> openhab:install-service

Starting openHAB system service installation...

Creating file: /Applications/openhab/runtime/karaf/bin/openHAB-wrapper Creating file: /Applications/openhab/runtime/karaf/bin/openHAB-service Creating file: /Applications/openhab/runtime/karaf/etc/openHAB-wrapper.conf Creating file: /Applications/openhab/runtime/karaf/bin/org.apache.karaf.openHAB.plist Creating missing directory: /Applications/openhab/runtime/karaf/lib/wrapper Creating file: /Applications/openhab/runtime/karaf/lib/wrapper/libwrapper.jnilib Creating file: /Applications/openhab/runtime/karaf/lib/wrapper/karaf-wrapper.jar Creating file: /Applications/openhab/runtime/karaf/lib/wrapper/karaf-wrapper-main.jar

Mac OS X system detected:

To configure openHAB as a user service execute the following file move:

mv /Applications/openhab/runtime/karaf/bin/openHAB.plist ~/Library/LaunchAgents/

To configure openHAB as a system service execute the following file move and authorisation changes:

sudo mv /Applications/openhab/runtime/karaf/bin/openHAB.plist /Library/LaunchDaemons/ sudo chown root:wheel /Library/LaunchDaemons/openHAB.plist sudo chmod u=rw,g=r,o=r /Library/LaunchDaemons/openHAB.plist

To test your service:

launchctl load ~/Library/LaunchAgents/openHAB.plist launchctl start openHAB launchctl stop openHAB

After restart of your session or system you can use the launchctl command to start and stop your service

For removing the service call:

launchctl remove openHAB

openhab> @dvanherbergen As you did the integration, any chance that you could have a look at fixing @rrgeorge's problem?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

kgoderis commented 8 years ago

FYI, when killing the fault karaf session (the one hanging), then suddenly the openhab:install-service continues.

dvanherbergen commented 8 years ago

If I remember correctly, the JAVA_HOME was not manipulated during the installation, so it should have been set by the underlying Karaf service installation. I'll have look, maybe we can force it.

dvanherbergen commented 8 years ago

I can't reproduce this issue on OSX 10.11.4. When I clear JAVA_HOME prior to launching openhab and installing the service, the generated config is still generated with the correct entry:

set.default.JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home

This is because the start.sh calls the setenv.sh, which uses /usr/libexec/java_home -v 1.8 to initialize the JAVA_HOME variable if it wasn't set yet. This value is then used during the generation of the wrapper.

@rrgeorge , did you start openHAB with the start.sh script? Can you still reproduce the issue?

kgoderis commented 8 years ago

@dvanherbergen I had the same issue as @rrgeorge on El Capitan, but I did not clear the JAVA_HOME beforehand.

rrgeorge commented 8 years ago

The issue I'm experiencing is likely due to the fact that I'm not running OpenHAB as myself. I have it running as a system user, and install/upgrade it with a script I run, as root, that finishes with a: su _openhab -c ./start.sh then I manually run install-service. But since it doesn't get JAVA_HOME correctly, I then have to manually edit the openHAB-wrapper.conf.

Trickx commented 6 years ago

This issue is still open. I can confirm the issue on a Mac OSx Sierra with openHAB 2.1. Putting "export JAVA_HOME=$(/usr/libexec/java_home)" into openHAB-wrapper.conf manually solves this issue for me. JAVA_HOME was not set before.

pkishino commented 6 years ago

Yeah,same problem here..clear JAVA_HOME, launch karaf, run install-service..mv to /Library/LaunchDaemons etc.. won't run.. tried editing wrapper.conf sitll not working.. manually running with ./start works fine..

pkishino commented 6 years ago

finally after much digging I got it working according to here: https://github.com/openhab/openhab-distro/issues/401